What is Simpson's paradox and when does it trap ML practitioners?
Written by the mlprep team · Updated
Explain Simpson's paradox with a concrete example. When does it appear in ML workflows? How do you detect it, and what does it tell you about the relationship between correlation and causation?
The paradox#
A trend that appears across subgroups can disappear or reverse when the subgroups are combined.
Classic example — kidney stone treatment:
| | Treatment A | Treatment B | |---|---|---| | Small stones | 93% (81/87) | 87% (234/270) | | Large stones | 73% (192/263) | 69% (55/80) | | Overall | 78% (273/350) | 83% (289/350) |
Treatment A is better in both subgroups, yet Treatment B looks better overall. How?
Because large stones (harder to treat) were overwhelmingly assigned to Treatment A (263 vs 80). Treatment A treated more of the hard cases. The size-of-stones variable is a confounder — it correlates with both the treatment assigned and the outcome.
The math#
Weighted averages combine subgroup rates with different weights. If subgroup sizes differ across groups, the aggregate can be dominated by whichever group got more weight — not by the true treatment effect.
Overall_A = 0.73 × (263/350) + 0.93 × (87/350) ≈ 0.78
Overall_B = 0.69 × (80/350) + 0.87 × (270/350) ≈ 0.83
B's aggregate is higher because most of B's patients had small stones (easy cases).
Where ML practitioners encounter this#
Model evaluation: overall accuracy looks fine, but the model performs poorly on minority subgroups. Reporting aggregate accuracy hides this. Fix: stratified evaluation by subgroup.
Feature importance: a feature may look positively correlated with the target in aggregate but negatively correlated within each user segment if segment size is confounded.
A/B testing: treatment and control groups aren't perfectly balanced on a confounding variable. If heavy users go to control (because of ramp-up order), aggregate results favor control even if treatment is genuinely better. Fix: randomization and pre-stratification.
Recommendation systems: items that are popular get shown more, accumulate more clicks, look more appealing — but popularity itself is the confounder. The item didn't get more clicks because it's better; it got more clicks because it was shown more.
Training data: a model trained on data where gender correlates with job level (due to historical hiring bias) will learn that correlation — causally wrong.
Detection#
- Identify potential confounders (variables that could affect both your predictor and outcome)
- Stratify your analysis by those confounders and compare direction of effects
- If direction reverses or magnitude dramatically changes after stratification, Simpson's paradox is at play
What to trust: aggregate or subgroup?#
Depends on the causal question. If you're assigning treatment to a random patient, condition on the confounder (use subgroup rates). If you're measuring the overall population effect regardless of stone size, aggregate is correct. The paradox forces you to be explicit about what causal question you're answering.
The aggregate is never "wrong" — it's answering a different question. Know which question you're asking.
Interview red flags#
- Treating the aggregate comparison as the answer without checking whether a confounder drives group membership.
- Concluding that the stratified result is always right. The causal structure decides which comparison answers the question.
- Reporting only overall model metrics without slicing by key segments, where reversals hide.
- Assuming randomization guarantees balance in every post-hoc segment you slice.
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
Simpson's paradox: a trend in subgroups reverses when aggregated, because a confounder affects both group membership and outcome. Classic signal: one treatment better in every subgroup but worse overall. In ML: hides model performance gaps on subgroups, corrupts feature importance, invalidates naive A/B comparisons if randomization isn't balanced on confounders. Fix: stratify by confounders, ask explicitly which causal question you're answering before choosing aggregate vs subgroup numbers.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- How does randomization in A/B testing protect against Simpson's paradox?
- If your model evaluation shows a Simpson's paradox across user segments, which metric do you report to stakeholders?
- How does the backdoor criterion in causal graphs help identify which confounders to control for?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions
How does causal inference differ from correlation-based ML, and when does it matter?
Walk me through how you'd design and analyze an A/B test
Explain Bayesian vs. frequentist thinking — when does each matter in ML?
How do you handle missing data without introducing bias?