Natural Language Analytics and Visualization¶
We can generate datasets using ChatGPT prompts. Then we can combine use these datasets for visualization and analytics.
What are the house price trends over last 10 years in Sunnyvale, CA? Only provide historically factual data and cite source of data. In response create a markdown table starting # (1)! with "```" markdown and closing with "```".
- Note that in the prompt "```" needs to be mentioned without enclosing quotes. We have used the enclosing quotes to ensure it renders as-is in our code block. You can also skip this part of the prompt if you do not want to copy-paste the markdown code for the table.
This generates a table of data and citing source of the data. Note that as you run this query a few times, the source of data and the values may vary. Asking for the source of the data along with the data ensures that the data is historically factual and not made up. You could even perform a sanity check by comparing the data with the source of data.
|Year||Median House Price in Sunnyvale, CA|
Source: Zillow Home Value Index. (n.d.). Sunnyvale home values. Zillow. https://www.zillow.com/sunnyvale-ca/home-values/
Next we instruct ChatGPT within the same chat session to generate code for vegalite charts. Vega-Lite is a high-level grammar of interactive graphics. It provides a concise, declarative JSON syntax to create an expressive range of visualizations for data analysis and presentation.
Visualize this table data by generating code for vegalite charts using bar charts.
Here is the visualization for the code that ChatGPT generates.
As you can see vegalite is an awesome library for visualizing data and the chart is interactive. You can hover over the bars to see the values. ChatGPT takes care of generating styled charts with gradients, colors, and legends, without any need for us to provide these instructions as part of the prompt.