In this article, I have created a Streamlit app that allows you to interact with the data, but it has limitations, for instance, when we use it.
Can you draw bar chart of yearly volume?
SS of the streamlit app
It won’t display the output due to the Pandas langchain agent limitation.
How to solve this?
We need to implement a new workflow. This workflow should detect the code this agent created and execute it.
Testing AI Agent v0.2
But not just this, you can also build a machine learning algorithm by just typing!
Train a machine learning model to predict price.
Here is the output.
But how?
If you don’t want to see how, here is the entire code.
The Breakthrough: Letting AI Write Code, Then Running It!
Created with Midjourney
If you don’t read our previous article, let me summarize it step by step.
Why?
Because we will take one step further.
How?
Here is the shortcut prompt that I learned from Reddit.
TLDR in five bullet points [paste-article-here]
Here is the summary for you.
Summary of the Streamlit Agent we built before in this article.
In short, we have built an Agent with Streamlit using Langchain (Pandas agent).
But it had limitations in code visualization and machine learning. We will solve this in 5 steps.
5 Steps
Step 1: Auto-Detect Prompts That Need Execution
Here we scan the code user input; if it includes keywords, the system knows what code should be generated.
(Between 391–399, 445, here.)
Step 2: Rewrite Prompt Based on Intent
The prompt will be rewritten for Machine Learning and data visualization.
Step 3: Extract Code From Response (Before Execution)
In this step, we extract the code from the AI’s response.
Extract-code
Step 4: Run the Code and Get Results
There are three different execution methods we are using;
- Local exec
- Judge0 API
- Piston API
This makes the code runnable through the cloud. If you do not want to execute locally, you can switch those API’s based on your project needs.
Step 5: Display Output Directly in Streamlit
After executing the code locally or remotely, the system renders results directly using Streamlit components.
st.pyplot():
for matplotlib/seaborn plotsst.plotly_chart():
for interactive Plotly visualsst.metric():
for Machine learning model performance scoresst.code():
for text outputs or printed logs
You can find the entire code here.
Testing the Streamlit Agent
After you finished everything, paste the code into an app, and name it, let’s say:
nocode.py
Go to this working directory on your terminal and run the following code;
streamlit run nocode.py
Here is the screen.
UI of the AI Data Analyst
Upload your data after clicking 'Browse File' and start interacting with the data.
AI assistant after uploading the data
Let’s start with the simple questions.
What is the average closing price across the entire dataset?
Here is the output.
AI Assistant output
Let’s create a graph.
Show me line graph How did the closing price change over time yearly
Here is the output.
Average Closing Price Over Time
Train a machine learning model to predict price.
Here is the output.
Machine Learning Evaluation Metrics
Train a machine learning model to predict price and draw a line graph to compare the actual price and the predicted price by using a line graph for each year
Here is the output.
Machine Learning Evaluation Metrics Visualized
Final Thoughts
Writing manual code is still great, but this no-code AI assistance can be a good way of getting inspired.
To discover similar no-code AI tools, check out our Substack. If you want to utilize no-code AI tools, such as agents or AI characters, visit our platform!
Here are the free resources.
Here is the ChatGPT cheat sheet.
Here is the Prompt Techniques cheat sheet.
Here is my NumPy cheat sheet.
Here is the source code of the “How to be a Billionaire” data project.
Here is the source code of the “Classification Task with 6 Different Algorithms using Python” data project.
Here is the source code of the “Decision Tree in Energy Efficiency Analysis” data project.
Here is the source code of the “DataDrivenInvestor 2022 Articles Analysis” data project.
“Machine learning is the last invention that humanity will ever need to make.” Nick Bostrom
Here are paid resources.
Here you can create your start-up ideas.
Here is our Substack page.