"In 1973, statistician Francis Anscombe published four datasets with identical means, variances, and correlations — but radically different shapes. Plot them and the story changes completely. Half a century later, juniors still fit models without looking at their data first. EDA is the cheapest insurance policy in ML: an hour of plots saves a week of mysterious model debugging."
Learning Objectives
After this lesson, you will be able to:
Use charts (histograms, scatter plots, box plots) to spot patterns, relationships, and weird outliers in your data
Calculate basic stats (mean, median, standard deviation, correlation) and know when each one can trick you
Follow a step-by-step 'explore first, model later' workflow on any new dataset to catch problems early and find useful patterns
Use automated EDA tools like pandas-profiling (ydata-profiling) to generate comprehensive distribution checks, correlation matrices, and data quality reports in seconds
Don't worry if all the different charts and stats feel overwhelming — you only need a few of them for most projects, and you will build the instinct with practice!
Exploratory Data Analysis (EDA) was formalized by John Tukey in his 1977 book of the same name. His revolutionary insight: before you test hypotheses, look at your data. Plot it. Summarize it. Ask questions. Let the data suggest hypotheses rather than forcing your assumptions onto it.
Critical caveat: Correlation does not imply causation. And more importantly for EDA, zero correlation does not mean no relationship. A perfect U-shaped relationship has r = 0. Always plot your data -- never rely on correlation alone.
Try it! Open the Python REPL and type these lines yourself. Generate a random dataset with import numpy as np; x = np.random.randn(100); y = x**2 and compute np.corrcoef(x, y)[0,1] — you will see correlation near zero even though y depends entirely on x!
A histogram bins continuous data into intervals and shows frequency. It reveals:
Skewness: Is the distribution symmetric, left-skewed, or right-skewed?
Modality: One peak (unimodal), two peaks (bimodal), or more?
Outliers: Isolated bars far from the main distribution?
Gaps: Missing ranges that suggest data collection issues?
Try it: Explore different distributions and watch summary statistics changeInteractive
Loading visualization...
Try this: Explore different distribution shapes. Notice how the mean and median diverge for skewed distributions. For symmetric distributions like the normal, they are nearly identical.
What Do You Think?
A dataset of employee salaries has a mean of $95,000 and a median of $62,000. What does this tell you about the distribution?
When the mean is significantly larger than the median, the distribution is right-skewed -- a long tail of high values pulls the mean upward while the median stays anchored at the center of the data mass. This is extremely common for income, wealth, company sizes, and website traffic.
A box plot compresses an entire distribution into five numbers:
Minimum (excluding outliers)
Q1 (25th percentile)
Median (50th percentile)
Q3 (75th percentile)
Maximum (excluding outliers)
Points beyond 1.5 * IQR from Q1 or Q3 are plotted individually as potential outliers.
Box plots are especially powerful for comparing distributions across categories -- salary by department, model accuracy by hyperparameter setting, response time by server.
Try it: Run your own EDA on a sample datasetInteractive
Switch between histograms, scatter plots, box plots, and a correlation matrix. Change features and bin counts to see how different views reveal different patterns in the same data.
Count nulls per column. Are missing values random or systematic? A column that is 90% null is probably useless. A column that is null only for one category might indicate a data collection issue.
pythonrunnable cell
1
2
df.isnull().sum() # nulls per column
df.isnull().mean() * 100 # percent null per column
Examine each variable individually. Histograms for numeric columns. Bar charts for categorical columns. Look for unexpected distributions, impossible values, and heavy tails.
Examine relationships between pairs of variables. Scatter plots for numeric-numeric. Box plots for numeric-categorical. Heatmaps for correlation matrices. Look for strong correlations, nonlinear relationships, and interaction effects.
Look at three or more variables simultaneously. Color scatter plots by a third variable. Use pair plots for all combinations. Detect confounders -- variables that create spurious correlations between others.
Write down what you learned. Which features seem predictive? Which have quality issues? What transformations are needed? This document becomes the blueprint for feature engineering.
The five-number summary (min, Q1, median, Q3, max) is the foundation of the box plot. But for ML, you often need more:
Skewness: Measures asymmetry. Zero for symmetric distributions. Positive means right-tailed.
Kurtosis: Measures tail heaviness. High kurtosis means more outliers than a normal distribution.
Cardinality: For categorical variables, how many unique values? A column with 10,000 unique values out of 10,000 rows is likely an ID, not a useful feature.
Null rate: What percentage of values are missing? Per column and per row.
Word frequency distributions, document length distributions, vocabulary size, language detection, n-gram analysis. Look for: encoding issues, mixed languages, extremely short or long documents.
Trend, seasonality, autocorrelation. Plot the raw series first. Decompose into trend + seasonal + residual. Look for: gaps in timestamps, irregular sampling, regime changes.
Always plot your data before modeling. Anscombe's Quartet proves that summary statistics alone can be deeply misleading; four datasets with identical means, variances, and correlations look completely different when visualized
Choose the right central tendency measure. Use the mean for symmetric data and the median for skewed data with outliers; when mean greatly exceeds median, the distribution is right-skewed
Correlation of zero does not mean no relationship. Pearson's r only measures linear association; a perfect U-shaped or circular relationship produces r near zero, so always combine statistics with scatter plots
Follow a systematic EDA workflow. Start with shape and types, check missing values, analyze univariate distributions, examine bivariate relationships, then document findings before building any model
EDA is continuous, not one-time. In production systems, automated EDA tools and feature stores monitor distribution drift and quality issues on every new data batch
Modern EDA workflows in 2026 lean on ydata-profiling, Sweetviz and Dataprep for one-line dataset summaries, then Polars or DuckDB for fast hypothesis-checking on data that doesn't fit in pandas memory. The instinct to look at your data for an hour before modeling has not changed; the tools just got faster.
Now that you can explore and understand your data, the next step is dealing with its imperfections. Next up: Data Quality and Cleaning -- how to handle missing values, outliers, and inconsistencies that would sabotage your models.