Mostrar mensagens com a etiqueta Python. Mostrar todas as mensagens
Mostrar mensagens com a etiqueta Python. Mostrar todas as mensagens

terça-feira, 24 de dezembro de 2024

Gen AI with SAP Cash flow

Um exemplo usando SAP Cash flow e AI generative para obter as perguntas que o usuário pode fazer ao nivel de fluxo de caixa financeiro.

Conexão foi feita com informações que vieram do aplicativo Cash Flow da Makevalue (Produto TVM/Cash Flow) e o desenvolvimento é em Python e FLASK.







quinta-feira, 3 de outubro de 2024

A utilização das API's para melhorar o atendimento ao ciidadão.

 



No mundo todo, os órgãos governamentais digitalizam seus processos, desenvolvendo aplicações que atendem o cidadão de forma automatizada e remota. Nesta jornada, cresce a cada dia o consumo e a publicação de APIs (Application Programming Interfaces).

É o que revela estudo com líderes de TI de organizações do setor público dos EUA com mais de 1.500 funcionários. Em quase três de cada cinco organizações (59%), as APIs conseguiram melhorar o atendimento ao cidadão e/ou aprimorar a produtividade do desenvolvedor. Vale destacar que 99% estão modernizando suas aplicações.

O Brasil é um grande polo de uso de APIs.  A MakeValue utiliza as API's bancárias para fazer toda a troca de informação sem necessitar de envio e recepção de arquivos.

Leia mais no artigo de Hilmar Becker, diretor regional da F5 Brasil:
Bagete Diario

segunda-feira, 15 de junho de 2020

A workflow system based on email and Google Forms




GOAL:

Use the information collected by Google Forms, to apply a process of sending email with python, managing the information registered in Google spreadsheet in a massive and automatic way.



Definition:
Workflow is the sequence of steps necessary to automate business processes, according to a set of defined rules, allowing them to be transmitted from one person to another.
In theory, this management can be organized manually, but currently most of the workflow is systematized in the context of information technologies, better known as IT systems.

What is workflow from a technological point of view and how does it improve business processes?

Workflow technology refers to a set of tools that, when viewed from a macro-environmental perspective, bridge the gap between eventual units and the office of a particular company.
In general, workflow technology not only guarantees communication and information exchange between different departments involved in the same business process, but also ensures that any and all tasks are performed by the employee for whom it is intended.

Development:

We need to develop 5 strategies to our work:
1.      Create a Google Forms (very easy)
2.      Define a key API to Google Drive
3.      Share the information for Google Spreadsheet, that contains the collected information from Google Forms
4.      Read Spreadsheet with python program to a pandas dataframe
5.      Create python program to send email, with the information from a pandas dataframe

Let’s go:

1    1. Create a Google Forms

Google Forms is a search administration application included in the Google Drive office suite, along with Google Docs, Google Sheets and Google Slides. Forms present all the collaboration and sharing features found in Documents, Spreadsheets, and Presentations. It is a powerful and easy and free way to create your inquiries and/or collect formatted information from your customers.
Go to https:https://docs.google.com/forms/  and create your form.



Google automatically creates a spreadsheet Google Spreadsheet associated with the form, where it will put all the information received from filling out the form. It's a spreadsheet, in the cloud. My example the spreadsheet created:

2     2. Define a key API to Google Drive

To access Google Drive with a program, we need to create our API. To create the API go to Google Console: https://console.developers.google.com/

A good work describes this process, here:




3.      Share the information for Google Spreadsheet, that contains the collected information from Google Forms

The last step gave us a key to use in our documents on Google Drive. This key is the element to whom we give sharing to our spreadsheet. Use the “client_email” information.




              
We can use this key to access the file in the python program.

4. Read Spreadsheet with python program to a pandas dataframe

We need to import gspread and oauth2client.

The file “Client_My_Drive_API_Secret.json” is created during the configuration tha Google API. It’s a JSON file that contains the Keys to access the Google Drive using a program. You need to put the JSON file in your work path.




5. Another way is to obtain a Key to the Spreadsheet.

For that we need to publish our Google Spreadsheet file: File > Publish on WEB > CSV format


In the Python program we access like that, to read the Spreadsheet and put then in a Pandas dataframe:




5.      I created a python program to send email, with the information from a pandas dataframe
 I tried 2 ways, once using email.mime functions and another using Yagmail. Its easier to use yagmail.

Need to import yagmail, and make I created a cycle that reads the pandas dataframe and calls the function sending email.



In the body we can use HTML to create a better design.



For the attachments only need to inform the path and name file to attach in the email. I tried to attach many types of files, including PDF, JPG, and ICS (for calendar appointments), with successful execution. One easier way to create ics files, I found the web page https://ical.marudot.com/, where we can define the event and download to a file ics format.

The result of email sent:



Conclusion


Process automation, digitization and industry 4.0 have a lot of innovation, often retrieving the pieces of software from each software house, incorporating much of the knowledge distributed across various platforms and languages. A practical example to manage safely and conveniently.

References:

terça-feira, 24 de março de 2020

Credit Score using Machine Learning

 The goal is to use machine learning to create a credit score for customers. This score gives the degree of confidence that the customer will meet the agreed payments. The higher the score, define the greater the probability of non-payment.

Multiple Linear Regression in Python with Scikit-Learn


We just performed linear regression in the above section involving two variables. Almost all the real-world problems that you are going to encounter will have more than two variables.



Linear regression involving multiple variables is called “multiple linear regression” or multivariate linear regression. The steps to perform multiple linear regression are almost similar to that of simple linear regression.

We will use customer information to generate a ‘trust’ score on the customer. The scoring formula can be adapted for each company according to its credit context. In this example, we are going to use the average number of days the customer is late, and the average billing amount for the past 2 years to calculate a score that combines the 2 information.

After calculating the score, we submit the information to a machine learning with Scikit-Learn, so that the system can predict new scores based on the learning information.

Our formula for Score calculation described on Score calculation.xlsx

Customer information is in the excel: Customers_CODE.XLSX


Customer company information:

  1. Customer from date
  2. State, Region, Postcode, Salesman, Main CNAE (type of company classification in Brazil)
  3. Highest Billing Date
  4. Maximum billing amount
  5. Last Date invoice issued
  6. Largest credit exposure date
  7. Highest credit exposure
  8. Average historical delay
  9. Average revenue last 48 months
  10. Amount payable Overdue
  11. Amount payable due
  12. Customer Last Order Date
  13. Date of this information

SERASA Information 

( Serasa it’s a company that sell’s information about other companies)
  1. Serasa Score
  2. Probability of not paying
  3. Last date non payment
  4. Amount of unpaid documents
  5. Value of unpaid documents
  6. Last date bad checks
  7. Amount of bad checks
  8. Last date protests
  9. Value protests
  10. Last date judicial actions
  11. Value judicial actions
  12. Last date overdue debts
  13. Value overdue debts

I create some Python code to read and clean data from my data set.

After we create a routine to read all records and calculate my score (newscore) using my definitions. I have an excel file with my definitions to calculate my score.


Applying Keras-Model to training and test the model. Create Train and Test datasets, 80% for Train and 20% to Test. In graphic mode, we can compare Train and Test results:


I need to predict some individual records, so, I made a python function to predict score:


Now testing, running to predict my record:
Using tkinter python library, we can create a screen with better visual:




Conclusion:

The creation of a score using the information known to a customer, can automate and make a credit system more reliable. This approach contributes to cooler and more reliable risk analysis, resulting only from market data and information, removing from the system the criteria of proximity to the client and the emotions that negotiation can generate.


References:


MY GITHUB

MY MEDIUM