Easy Methods for Causal Inference

Robert Kübler20 Feb 2024

Problem

A team has a good churn model, but the business asks what to do about it. If we give this customer a coupon or a membership upgrade, how does the churn probability change? That is a causal question, and an ordinary model learns only correlations. Fed the wrong features, it suggests actions that do not work.

Example from the article: in a table of employees with Sense of duty, Overtime, Income and Happiness, predicting Income from the other three features and then varying Overtime gives a wrong answer about the effect of overtime on income.

Solution in brief

First choose features that form a sufficient adjustment set, using a causal graph and the DAGitty web tool. Then turn any ordinary model into an effect estimator with a meta-learner. The S-learner toggles the treatment column of one model between 1 and 0. The T-learner trains one model per treatment group. The difference of predictions is the uplift per row.

Questions this case answers
  • How to estimate the individual effect of a binary intervention on an outcome from observational data with an ordinary predictive model, when naive what-if predictions pick up confounding
  • How to estimate what a coupon or other intervention does to each customer's churn using a model I already have?
  • How to choose which features to feed a model so that its what-if predictions are causal and not just correlational?
  • How to compute the uplift of a binary treatment per row and its average over the dataset?

Tools and methods

  • Causal graph, DAGitty — pick the adjustment set of features; DAGitty (dagitty.net) checks it.
  • S-learner — one model with the treatment as a feature.
  • T-learner — two models, one per treatment group.
  • EconML, CausalML — libraries with meta-learners.
  • scikit-learn, Polars — used in the author's implementation.
Continue reading — it's free

Google or a one-time email code. No password.