Data and modeling
Machine learning for causal inference
In causal inference, machine learning estimates the parts of a model that are hard to specify by hand, such as how outcomes and treatment assignment depend on many covariates. It powers double machine learning, uplift modelling for marketing, and treatment effects that vary across groups.
How machine learning is used in causal inference
Estimating an average treatment effect
Double machine learning uses flexible models to predict both the outcome and the treatment from many covariates, then estimates the effect from what those models cannot explain. This keeps valid confidence intervals while avoiding hand-picked functional forms.
Real exampleDouble/Debiased Machine Learning (Chernozhukov et al., 2016)The paper shows how to use machine learning for nuisance parameters while still obtaining valid inference on treatment and causal parameters.
Finding who benefits most
Treatment effects often differ across people, so analysts estimate a conditional effect for each combination of covariates. Causal forests adapt random forests to this task and report confidence intervals.
Real exampleCausal forests (Wager and Athey, 2018)The authors develop a random forest method for estimating heterogeneous treatment effects with valid asymptotic confidence intervals.
Uplift modelling in marketing
Uplift models predict how much a message, discount or call changes a customer's behaviour, rather than who is likely to buy anyway. Campaigns then target the people the treatment actually moves.
Real exampleCausalML (Uber, open source)Uber's Python package provides uplift modelling and causal inference methods built on machine learning algorithms.
Benchmarking methods on randomised data
Because true causal effects are rarely observed, methods are tested on data from randomised experiments, where an unbiased estimate is available. Large public experiment logs make this possible at realistic scale.
Real exampleCriteo Uplift Prediction DatasetCriteo AI Lab released the dataset with the paper 'A Large Scale Benchmark for Uplift Modeling' to support research on uplift modelling.
Can you learn machine learning for causal inference?
Yes, if you are comfortable with regression and probability. Causal machine learning combines classical causal thinking, potential outcomes, confounding and identification, with supervised models used as building blocks. Learn the statistics and the causal assumptions before the estimators.
- Python and data handlingPrepare treatment, outcome and covariate tables in pandas and check balance between treated and untreated groups.Learn it in Data Tools
- Statistics and estimationLearn estimation, standard errors and hypothesis testing, and how randomised experiments give unbiased effects.Learn it in Statistics
- Supervised models as building blocksFit and cross-validate regression, classification and tree ensembles, since causal estimators use them to predict outcomes and propensity scores.Learn it in Machine Learning
- Causal identificationStudy potential outcomes, causal graphs, confounding and overlap, then apply DoWhy and EconML to estimate effects and run refutation tests.
Moving into causal machine learning
If you already work in the field
Economists, epidemiologists and experimentation analysts already think in terms of confounding and identification. Add cross-fitting and flexible learners, then re-estimate a published or past effect with double machine learning and compare it with your original estimate.
If you come from data science or ML
If you come from predictive ML, the key shift is that a good predictive score does not make an effect estimate correct. Learn causal graphs and the assumptions each estimator needs, and practise on experimental data where you can check the answer.
Roles that do this workCausal inference scientistEconomist (tech)Experimentation data scientistMarketing scientistEpidemiologist
Tools you will use
| Tool | What you use it for |
|---|---|
| DoWhy | Encode causal assumptions as a graph, estimate an effect and run refutation tests. |
| EconML | Estimate varying treatment effects with double machine learning and causal forests. |
| CausalML | Build uplift models that rank who responds to a treatment. |
| statsmodels | Fit regression and propensity-score models with interpretable coefficients. |
| scikit-learn | Supply the flexible outcome and treatment models used inside causal estimators. |
Public data to practise on
- LaLonde NSW data (Dehejia and Wahba): Experimental and observational samples from a job-training programme, a classic test for causal estimators.
- Criteo Uplift Prediction Dataset: Advertising treatment and control groups with visit and conversion outcomes, for uplift modelling.
Your first project
Download the LaLonde NSW job-training data, estimate the effect of training on 1978 earnings with propensity-score weighting on the observational comparison group, and measure how far it lands from the experimental difference in means.
Common questions
Can machine learning find causal relationships?
Not on its own. Machine learning finds patterns that predict well, and a causal claim needs assumptions about how the data were generated, or a randomised experiment. Causal ML methods use models inside a design that makes those assumptions explicit.
What is double machine learning?
It is a method that predicts the outcome and the treatment from covariates with flexible models, uses cross-fitting to avoid overfitting bias, and estimates the effect from the remaining variation. It gives confidence intervals for the effect.
What is the difference between uplift modelling and response modelling?
Response modelling predicts who will buy or respond. Uplift modelling predicts the difference the treatment makes, so it avoids spending on people who would have responded anyway.
Which Python libraries are used for causal inference?
DoWhy for modelling assumptions and refutation, EconML and CausalML for effect estimation, and statsmodels for classical regression-based estimates are common choices.
Courses for these skills
- Statistics and Probability for Machine LearningUnderstand base rates, sampling and uncertainty.41 published lessons · all planned lessons open
- Practical Machine Learning in PythonStudy classification, thresholds and evaluating predicted probabilities.51 published lessons · more lessons in production
New to programming or maths? Start with Python, or follow the machine learning path in order. Published lessons are free to read; compare Free and Pro.