[HN Gopher] Show HN: PlotAI - Create Plots in Python and Matplot...
       ___________________________________________________________________
        
       Show HN: PlotAI - Create Plots in Python and Matplotlib with LLM
        
       Author : pplonski86
       Score  : 40 points
       Date   : 2023-08-25 12:25 UTC (10 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | bfeynman wrote:
       | 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
        
       | westurner wrote:
       | 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
        
       | lappa wrote:
       | 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.
        
       | pplonski86 wrote:
       | 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 wrote:
         | 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
        
           | pplonski86 wrote:
           | 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.
        
             | jncfhnb wrote:
             | Wait... really? What exactly is it outputting as code for
             | that? That seems shocking.
        
       | jncfhnb wrote:
       | I have never seen someone pass a triple quote string as an
       | argument before like in the demo mp4.
        
         | bagels wrote:
         | I use it all the time for copy pasting text from the web or
         | spreadsheets that I want to parse.
        
         | baq wrote:
         | it's also used as a block comment, when if False: is
         | inconvenient
        
         | pplonski86 wrote:
         | I needed multi-line string, because I know that there will be
         | several iterations of prompt creation.
        
       ___________________________________________________________________
       (page generated 2023-08-25 23:01 UTC)