Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: PlotAI – Create Plots in Python and Matplotlib with LLM (github.com/mljar)
51 points by pplonski86 on Aug 25, 2023 | hide | past | favorite | 13 comments


Vega and Vega-lite visualization grammars: https://en.wikipedia.org/wiki/Vega_and_Vega-Lite_visualisati...

FWIU Vega/voyager suggests similar charts with CompassQL: https://github.com/vega/voyager

From 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


Again, 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


This 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.


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).


Is 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


The 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.


Wait… really? What exactly is it outputting as code for that? That seems shocking.


Hey 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.


Hey! 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


I have never seen someone pass a triple quote string as an argument before like in the demo mp4.


I needed multi-line string, because I know that there will be several iterations of prompt creation.


I use it all the time for copy pasting text from the web or spreadsheets that I want to parse.


it's also used as a block comment, when if False: is inconvenient




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: