Every summer, two numbers rise together: ice-cream sales and
drownings. Plot one against the other and you get a gorgeous, strong
This is the deepest trap in all of data science. Models are built on correlations, but decisions require causation — and the two come apart constantly. Causal inference is the set of tools for telling them apart.
The picture below is a causal diagram (a directed acyclic graph, or DAG): an arrow
The weather
1. Adjust for it (condition). If you compare ice-cream sales and drownings
within days of the same temperature — all the 30 °C days together, all the 10 °C days
together — the spurious link vanishes. Statistically this is what a regression does when you add the
confounder as a control variable, or what
2. Randomise it (intervene). If you could assign ice-cream consumption at
random — coin-flip who gets ice cream regardless of the weather — then by construction the weather no
longer influences
In 1973 Berkeley was accused of admitting men at a higher rate than women. Overall, it was true — 44% of men admitted versus 35% of women. But when statisticians looked department by department, most departments actually favoured women slightly. How? Women applied in larger numbers to the most competitive departments, which admitted few of anyone. The department was a confounder, and pooling across it reversed the apparent effect. That's Simpson's paradox: an association can point one way in aggregate and the opposite way inside every subgroup. The lesson is not "always disaggregate" — it's that which variables you adjust for is a causal question you cannot answer from the numbers alone.
It is tempting to throw every available variable into a regression as a control. This is wrong, and it
can create bias rather than remove it. Adjusting for a collider — a variable
that is a common effect of
Predictive models are perfectly happy with confounded correlations — a spam filter doesn't care why a word predicts spam. But the moment someone asks "what happens if we change this?" — raise the price, send the email, prescribe the drug — you have left prediction and entered causation, where correlations mislead. Recognising a confounder in a causal diagram, and knowing to reach for adjustment or randomisation, is what separates a real recommendation from a dangerous one.
Kaggle Learn's Intro to AI Ethics course explores how confounding and biased data lead models to unfair and wrong conclusions, and the broader Kaggle community hosts many notebooks on A/B testing and causal analysis in Python — good places to see these ideas applied to real datasets.