Unit 3 / 11

Exploratory Data Analysis and Visualization: Graphing and Interpretation with Artificial Intelligence

Gains:

  • Ability to produce descriptive statistics and distribution/relationship charts with artificial intelligence support and choose the right chart type according to the data and question
  • Ability to recognize misleading choices (dashed axis, inappropriate scale, excessive smoothing) in images produced by artificial intelligence and apply honest visualization principles
  • Being able to distinguish that exploratory analysis is for generating hypotheses and the trap of making discovery and confirmation with the same data (which opens the door to p-hacking).

After cleaning the data, the empirical researcher's first job is to get to know it. This stage is called exploratory data analysis (EDA - Exploratory Data Analysis): it is the process of examining the data with graphs and summary statistics and seeing its structure, patterns and surprises. The aim is not to test a hypothesis yet, but to get acquainted with the data, generate questions and lay the groundwork for the model you will build in the future. In this unit, we will see how artificial intelligence (AI) accelerates EDA and visualization, but why the graphics it produces must be carefully audited.

Let's first make two basic distinctions. First, descriptive statistics (numbers that summarize data such as mean, median, standard deviation, quartiles) and visualization (showing the same information graphically) complement each other; Together they describe the data. Second, and most critical: discovery and confirmation must be distinguished. Exploratory analysis is for generating hypotheses; Exploring the hypothesis with the same data and saying "I tested it and found it significant" opens the door to p-hacking, which we will see in the next unit. It is free to look at the data and see a pattern; But declaring that pattern a "proven finding" in the same data is misleading.

Step by step exploratory analysis

1. Univariate view. Examine each variable individually: is its distribution symmetrical or skewed; how many hills are there; Where are the outliers? For numerical variables, histogram (plot showing frequency by dividing values ​​into ranges) and boxplot (boxplot — chart showing median, quartile and extreme values); For categorical variables, use frequency tables and bar charts.

2. Bivariate view. See the relationship between two variables: scatter plot for two numerical variables (shows each observation as a point on the x-y plane), grouped box plot for numeric-categorical, crosstab for two categorical. Before looking at the correlation coefficient, be sure to look at the scatter plot: the same correlation can show very different patterns (the famous Anscombe quartet demonstrates this; four data sets have almost identical statistics, but when plotted they turn out to be completely different).

3. Choose the correct chart type. The chart type depends on your question and data type. Histogram for distribution; scattering for relationship; line chart for change over time; bar chart for category comparison; (carefully) stacked bar for the ratio of parts to the whole. AI quickly generates code for you, but the decision of "which graph for which question" is yours.

4. Note the pattern, don't declare results. Record any interesting pattern you see as a "discovery note," but don't consider it a confirmed finding. Confirmation is done in a separate step, preferably with separate data or a predetermined schedule.

Honest visualization principles

The graphic convinces; Therefore, its misleading power is also high. AI can make aesthetic but sometimes misleading choices. Check these policies:

  • In bar charts, the y-axis must start at zero. The dashed axis shows small differences as large.
  • The scale should be consistent. If two charts are being compared, use the same axis range.
  • Excessive smoothing can hide the true pattern. A trend line looks nice, but if it "smoothes" the data too much, it can be misleading.
  • Color and 3D decoration distort attention, not data. Choose simplicity.
  • Missing data and sample size should be visible. "n=12" and "n=12,000" should not look the same.
Attention: Just because the graphics produced by AI are beautiful, they are not true. The most common mistake he makes is not starting the axis from zero in the bar chart and exaggerating the difference between the two groups. Always check the axis.

Comparison chart: question → chart

Ask

correct chart

Common mistake

How is this variable distributed?

Histogram/box plot

use pie chart

Are two numeric variables related?

Scatter plot

Just looking at the number of correlations

How has it changed over time?

line chart

Telling a trend with a bar chart

What is the difference between groups?

Grouped box/bar (from scratch)

Truncated axis rod

Part-to-whole ratio?

Stacked bar (with caution)

Multi-slice pie chart

Four copyable prompts

1. Auto discovery code:

Your role: EDA assistant. I do not share the data, I want the R (ggplot2) code. There are numerical (income, age, expenditure) and categorical (region, education) variables in the 'data' data.frame. Task: write code that produces a histogram for each numeric, a bar chart for each categorical, and a scatter plot for income~age. In bar charts, let the y-axis start from ZERO. Add comment line.

2. Correlation review (correlation + visual together):

Write code that both calculates Pearson correlation for income and spending and plots a scatter plot + linear trend. Add a comment line reminding me to examine the chart before TRUSTING the correlation count (Anscombe warning). Don't over-smooth the trend line.

3. Integrity audit:

Check the following ggplot code for honest visualization:[code]. Check and correct the following: does the y-axis start from zero, is the scale consistent, is the sample size visible, is there excessive smoothing? Explain the justification for each correction you made.

4. Producing a discovery note (not a finding):

Based on the graphs I produce, list OBSERVATIONS as a 'discovery note'; write each item in the language of 'hypothesis to be tested', not 'conclusive finding'. Example: 'Income in higher education SEEMS more spread out; should be tested with separate data.' Avoid causal and definitive statements.

Weak prompt / Strong prompt

Weak prompt:

Make nice graphs from the yield and tell me what they mean.

This prompt invites misleading output: “beautiful” focuses on aesthetics, while “what it means” pushes AI to jump from discovery to definitive conclusion. Causal, exaggerated comments follow.

Powerful prompt:

Your role: honest EDA assistant.Task: (1) choose the type of chart that suits my question and write the justification,(2) start the axis from zero in bar charts,(3) interpret the output in DISCOVERY NOTE language: no definitive/causal claim suggest hypothesis in "must be tested" language,(4) warn me if the sample is small (n<30).I will run the chart in my own environment and verify it.

Difference: strong will justifies the chart type, imposes rules of honesty and does not confuse discovery with confirmation.

three mini cases

Case 1 — Discrete axis exaggeration. An analyst showed the satisfaction scores of two branches (7.8 and 8.0; out of 10) in a bar chart. When starting the YZ axis from 7.5, the second branch appeared almost twice as high as the first; whereas the difference was only 2.5%. Management was about to reward a branch under the wrong impression. When I started the axis from scratch the difference was almost invisible. Lesson: axis choice alone changes perception.

Case 2 — Trusting the correlation and skipping the chart. A researcher saw r = 0.81 between two variables and wrote "strong linear relationship". When his consultant asked for the scatter plot, it was seen that the relationship was actually due to a single extreme observation, and when that point was removed, the correlation dropped to 0.12. Lesson: correlation count is no substitute for a graph; always look at the scatter.

Case 3 — Confusing discovery with confirmation. One student looked at all pairwise correlations in a 40-variable data set, selected the highest one (r=0.52) and wrote, "we found a significant relationship between education and savings (p=0.004)." However, there were hundreds of pairs in 40 variables; choosing the highest was a false finding due to chance. Lesson: the pattern discovered cannot be “tested and declared significant” in the same data; Separate confirmation is required.

Common mistakes

  • Not starting the axis from zero in the bar chart. It exaggerates the small difference; The most common visual lie. Always check.
  • Looking at the correlation and skipping the chart. The same correlation comes from very different patterns; can fit an outlier relationship. First, scattering.
  • Considering the pattern found in the discovery as "evidence" in the same data. This is the gateway to p-hacking; Confirmation is done separately.
  • Wrong chart type. Matches such as bar for trend and pie for distribution are misleading. Choose a genre based on the question.
  • Hiding the sample size. n=8 and n=8,000 should not look the same on the same graph; uncertainty must be shown.
Tip: Before publishing a chart, ask yourself: "Would the story change if I changed the axis?" If the answer is yes, you probably started the pivot from a dishonest place.

In summary

Exploratory data analysis is the phase of meeting the data, seeing patterns and generating hypotheses; It is not a confirmation. The AI ​​quickly generates descriptive statistics and graph code, but you choose the graph type based on your question and control the principles of fairness (zero axis, consistent scale, apparent uncertainty). Look at the scatter before trusting the correlation number; Do not declare the pattern you found in discovery as "evidence" in the same data. A beautiful graph of AI does not mean a correct graph.

Application task

Select at least three variables in a data set. Ask the AI ​​for and run code that produces exploratory graphs (histogram, scatter, boxed) with a prompt that enforces honesty rules. For each chart: check (1) the appropriateness of the chart type to the question, (2) the honesty of the axis, (3) the visibility of the sample size. Write at least one “discovery note” in hypothesis language (“…appears to be tested separately”). Examine a correlation with both count and scatter and report if there is a discrepancy between them.

checklist

  • [ ] I chose the chart type based on my question and data type.
  • [ ] In bar charts, I start the y-axis from zero; I checked the axis honesty.
  • [ ] I looked at the scatterplot before trusting the correlation.
  • [ ] I reflected the sample size and uncertainty on the graph.
  • [ ] I wrote the patterns I found in exploration as "hypothesis to be tested" rather than "evidence".
  • [ ] I noted that I would not use the same data for confirmation and that a separate step was required.