3 ms·
The easiest way to create plots in Python and Matplotlib. The plotai is using LLM to generate code and plots. The idea: 1. User provides input DataFrame and p
by pplonski86 3y ago
The easiest way to create plots in Python and Matplotlib. The plotai is using LLM to generate code and plots.
The idea:
1. User provides input DataFrame and prompt.
2. The PlotAI constructs a prompt for LLM, which contains the first 5 rows of DataFrame and the user's prompt and asks for Python code as output.
3. Returned Python code is executed, and the plot is displayed.
The simplest possible API for plotting:
# import packages
import pandas as pd
from plotai import PlotAI
# create some data
df = pd.DataFrame({"x":[1,2,3], "y": [4,5,6]})
# do a plot
plot = PlotAI(df)
plot.make("scatter plot")
The PlotAI class has only one method, make().
It works in Python scripts and in notebooks (Jupyter, Colab, VS Code).
- jncfhnb 3y agoIs the LLM looking at the properties of the data frame under the hood in addition to reading the prompt? That’s kind of cool. Edit: the content aware edits are very cool. I could not be arsed to adjust individual data points. Eg rotate just the Australia label
- pplonski86 3y agoThe LLM has access to user prompt, 5 first rows of DataFrame and template prompt (for example with sentence 'Output only Python code in response'). I was very surprised with Australia example! The LLM has access to only first 5 rows of the DataFrame and Australia is not there. The LLM was able to produce the correct code, that genralizes well on full DataFrame.
- jncfhnb 3y agoWait… really? What exactly is it outputting as code for that? That seems shocking.