
Predictive Isn't Causal: Why a Model Can't Tell You What to Change
- كاتب موثّق
محتويات المقال
The common misconception
Coefficients and feature importances read like effect sizes: "each year of education adds this much an hour." Dashboards call top features "drivers" of churn or revenue, and the word sticks. A model that scores well on held-out data feels like it has captured how the world works.
What actually happens
A confounder makes a bystander look like a driver
Accuracy can't warn you
A what-if on the model is still a prediction
import numpy as npfrom scipy.special import expit # the logistic functionfrom sklearn.linear_model import LogisticRegressionrng = np.random.default_rng(0)n = 20_000engaged = rng.normal(size=n) # what really drives retentionsessions = engaged + rng.normal(size=n) # a noisy, logged trace of itnotify = engaged + rng.normal(size=n) > 0 # engaged users opt instays = rng.random(n) < expit(2 * engaged + 0.3 * notify) # small real effectX = np.column_stack([notify, sessions])model = LogisticRegression().fit(X, stays)on, off = X.copy(), X.copy()on[:, 0], off[:, 0] = 1, 0 # "what if everyone / no one had notifications?"lift = (model.predict_proba(on)[:, 1] - model.predict_proba(off)[:, 1]).mean()print(f"Model's what-if: notifications add {lift:+.3f} to retention")# Model's what-if: notifications add +0.265 to retentionimport numpy as npfrom scipy.special import expitrng = np.random.default_rng(0)n = 20_000engaged = rng.normal(size=n) # the same users as beforenotify = rng.random(n) < 0.5 # A/B test: a coin decidesstays = rng.random(n) < expit(2 * engaged + 0.3 * notify) # same worldlift = stays[notify].mean() - stays[~notify].mean()print(f"A/B test: notifications add {lift:+.3f} to retention")truth = (expit(2 * engaged + 0.3) - expit(2 * engaged)).mean()print(f"True effect, known only in a simulation: {truth:+.3f}")# A/B test: notifications add +0.042 to retention# True effect, known only in a simulation: +0.045sessions didn't save the model: a noisy trace of engagement only removes part of the confounding. Flipping a column in predict_proba doesn't simulate an intervention; it asks the model about users who look like they have notifications on, and in the logged data those are the engaged ones. The coin breaks that link: engaged and casual users land in both groups alike, so any difference left is the notifications.
Importance describes the model, not the world
How to apply it in your project
Name the question first Write down whether the goal is to predict an outcome or to choose an action. "Who will churn?" and "what reduces churn?" need different evidence. Use experiments for causal questions When you can randomize, run an A/B test. Randomization handles confounders you didn't measure and don't even know about. State your assumptions when you can't Without an experiment, list the confounders you believe exist and whether you measured them. scikit-learn's example points to methods such as instrumental variables for this case; bring in someone who knows them. Report importances as reliance, not influence Write "the model relies on sessions", never "sessions drive retention". The first is what the tools measure. Watch the model after acting on it If your model's decisions change who gets treated, monitor it on fresh data, and keep the random holdout running.
Key takeaways
A feature that predicts an outcome may only travel with its real cause; changing it can do far less than the model implies. Accuracy doesn't reveal confounding: in scikit-learn's example, test R² was 0.975 with the confounder and 0.968 without it. Flipping a feature in predict_probais still a prediction: here it claimed +0.265, while the A/B test measured +0.042.Answer causal questions with randomized experiments or explicit causal assumptions, and keep a random holdout when a model drives actions.
📚 المصادر
Failure of Machine Learning to infer causal effects — scikit-learn examples Common pitfalls in the interpretation of coefficients of linear models — scikit-learn examples Permutation feature importance — scikit-learn User Guide Intelligible Models for HealthCare: Predicting Pneumonia Risk and Hospital 30-day Readmission — Caruana et al., KDD 2015 (PDF)
التعليقات (0)