The document discusses connecting an AI model to Python using HTTP requests. It covers converting pandas dataframes to dictionaries, using the requests module to send HTTP requests to an AI, and interacting with a mood classification AI by copying code from its integration page. The JSON module is also discussed for converting response dictionaries to strings. An exercise is provided to calculate accuracy and confusion matrix by sending dictionary formatted mood data through the AI service.
3. Statistics of columns/features – how does it
help?
• Describes the range of different features
• Understand the range of feature the machine learning algorithm trained
with
• Variation within features
• Standard deviation indicates the variation of data within the range
9. Kaggle datasets
• Mobile price prediction
• Fish Weight Prediction
• Heights and Weights
• Student performance prediction
• Predict Airline Passenger Satisfaction
10. Pandas dataframe to dictionary conversion
• Upload the mood dataset file to your repl program. Link
11. Pandas dataframe to dictionary conversion
• Import a csv file and execute the code below
12. Pandas dataframe to dictionary conversion
• What is the datatype of records_array variable?
13. Pandas dataframe to dictionary conversion
• What is the datatype of each entry of the records_array
variable?
14. Exercise
• Retrieve the 10th row of the dataset mood_project_3.csv in the
dictionary format.
15. Requests module in python
• This module helps you to send HTTP requests in python
• What are HTTP requests?
16. Requests module in python
• This module helps you to send HTTP requests in python
• How to use HTTP requests to interact with an AI?
17. Requests module in python
• This module helps you to send HTTP requests in python
• How to use HTTP requests to interact with an AI?
url: The http url to send request to
data: String containing the payload (features in case of AI)
18. Requests module in python
• This module helps you to send HTTP requests in python
• How to use HTTP requests to interact with an AI?
Example:
data: {“Sentence”: “I am sad”}
19. Lets connect your AI with python
• Login to your Navigator accounts and select the mood AI
20. Lets connect your AI with python
• Login to your Navigator accounts and select the mood AI
• Click on the integration tab in the monitor tab
21. Lets connect your AI with python
• Login to your Navigator accounts and select the mood AI
• Click on the integration tab in the monitor tab
• Select python from the drop down for connectors
22. Lets connect your AI with python
• Login to your Navigator accounts and select the mood AI
• Click on the integration tab in the monitor tab
• Select python from the drop down for connectors
• Copy paste the code into your repl account
23. Lets connect your AI with python
• Login to your Navigator accounts and select the mood AI
• Click on the integration tab in the monitor tab
• Select python from the drop down for connectors
• Copy paste the code into your repl account
24. Lets connect your AI with python
• Copy paste the code into your repl account
• Note that the code is a function, you have to call this function to get
the prediction
json.dumps() converts
dictionary to striing
Convert the output you
receive into readable format
25. JSON module
• JSON (JavaScript Object Notation)
• A very popular format to transmit and receive data over web
26. JSON module
• JSON (JavaScript Object Notation)
• A very popular format to transmit and receive data over web
• How does it work in python?
• A json is a string
27. JSON module
• JSON (JavaScript Object Notation)
• A very popular format to transmit and receive data over web
• What would the json dump of a dictionary be?
28. JSON module
• JSON (JavaScript Object Notation)
• A very popular format to transmit and receive data over web
• How does it work in python?
• Can any type of variable be dumped? Strings? Lists?
29. Lets connect your AI with python
• Login to your Navigator accounts and select the mood AI
• Click on the integration tab in the monitor tab
• Select python from the drop down for connectors
• Copy paste the code into your repl account
• Upload the mood dataset into repl
30. Exercise
• Convert the mood dataset rows into dictionaries
• Trigger the AI service
• Calculate accuracy across all samples of the dataset
• Calculate the confusion matrix
31. Popular ML Metrics - Classification
• Precision
• Recall
• ROC curve
• How to do it when there are more than 2 classes?