4 ms·
Show HN: PlotAI – Create Plots in Python and Matplotlib with LLM
- pplonski86 3y agoThe 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.
- jncfhnb 3y agoI have never seen someone pass a triple quote string as an argument before like in the demo mp4.
- pplonski86 3y agoI needed multi-line string, because I know that there will be several iterations of prompt creation.
- bagels 3y agoI use it all the time for copy pasting text from the web or spreadsheets that I want to parse.
- baq 3y agoit's also used as a block comment, when if False: is inconvenient
- bfeynman 3y agoAgain, just a trivial wrapper over open ai, which already does this very well. But seems to not have any real benefits other than not needing to move mouse. You don't need to send data to OpenAI, and in a business you wouldn't want to do that. LLMs already generate synthetic data for graphing that you just copy/paste in and use. It should instead be passing in types and header maybe. The big thing for graphs is formatting, the ideal solution IMO is one that can JIT code gen parts that generate real code for formatting so you can reuse and tweak, I don't need to pay to send request to increase the marker size by one pixel. Even if running locally that's waste of compute
- lappa 3y agoThis is great! If I could suggest changes that would make this especially useful for me and likely others it would be 1) The ability to substitute in your own LLM, specifically I'd like to be able to use Code Llama which was released a few days ago. 2) The ability to automatically determine an appropriate plot type based on natural langugae metadata. This would allow me to bulk process labelled timeseries data. For example if I set the X label as date, it should know to make a line chart. If I present data labelled with a description involving as "percent of" or something the LLM should know to use a pie or bar chart. If I give a description involving quarterly revenue, it should know it's a time series, but with discrete values, so a bar chart with negative and positive values, etc.
- westurner 3y agoVega and Vega-lite visualization grammars: https://en.wikipedia.org/wiki/Vega_and_Vega-Lite_visualisation_grammars https://en.wikipedia.org/wiki/Vega_and_Vega-Lite_visualisati... FWIU Vega/voyager suggests similar charts with CompassQL: https://github.com/vega/voyager https://github.com/vega/voyager From http://vega.github.io/ http://vega.github.io/ re: CompassQL: > COMPASSQL is a visualization recommendation engine. Given user query, it suggests visualizations, ranked by both data properties and perceptual principles Altair is one implementation of Vega-lite in Python; for rendering charts with JS. mpld3 does matplotlib with d3.js: https://github.com/mpld3/mpld3 https://github.com/mpld3/mpld3
- JPKab 3y agoHey dude! I met you a long time ago when you came to Colorado from Europe to demo mljar to a potential acquisition. My employer at the time was potentially interested in buying mljar, but I was overruled and they passed on you. It was a bad decision and I'm glad to see you're doing cool things now.
- pplonski86 3y agoHey! Thank you. I appreciate you response! That was wild run. Emotional roller coaster. Anyway, I made mljar AutoML open source, it is available in our github https://github.com/mljar https://github.com/mljar