Discussion 4: Data visualization vibecoding
Discussion 4: Data visualization vibecoding
STATS 60 / STATS 160 / PSYCH 10
Using AI for data visualization
Today: use AI to program visualizations for the data we collected last Friday!
If you have not already done so, please download a copy of the Colab file here: <div style=”display: flex; justify-content: “right”; flex-direction: column; align-items: “right”;”>
Together we’ll go through examples of how to “vibecode” each of the graphic visualizations we saw in class on Wednesday:
a. Pie chart
b. Bar chart
c. Histogram
d. Scatterplot
We will not do a time series, because we didn’t make any consistent measurements over time.
Then, you explore! Use AI to program your own data visualizations using our collected class data.
Exploring data with AI visualizaitons
Make one of each of the following types of graphics to represent data from our course entry survey:
a. Pie Chart
b. Bar Chart
c. Histogram
d. Scatterplot
Helpful information:
Accessing the data: the data comes in three “dataframes;” each dataframe is a table; each column represents the answers to a question.
Our datasets: the data is split into three different “dataframes” in order to keep things more manageable:
“demographic” contains demographic information, each row is a students’ responses
“numerical” contains some numerical data, each row is a students’ responses
“scrambled” contains answers to the rest of the questions, but the columns are randomly scrambled for anonymity.
Typos and whitespace: When you ask Colab to plot data in a column of your table, you should use the name of the column. Colab is sensitive to the precise column names, watch out for typos, even innocuous typos like omitting a space!
Prompt engineering: Varying your prompt in an innocuous way can have a large effect on the code output. If you’re not getting the output you want, you have a couple of options:
Try to modify your prompt so that you explicitly tell the AI agent not to do the undesirable behavior.
Alternatively, try to read the code itself, and see if you can use context clues to figure out which lines are problematic. Then, either modify them or give the AI agent a more targeted prompt in a new code cell, pointing out the problematic lines.