σ StatsDoge Causal inference workflows
11
Workflow·4 steps·branched

Uplift modelling with S-, T-, X- and R-learners (CausalML)

Source CausalML — Uber (Chen, Harinen, Lee, Zhao et al.)
Summary by StatsDoge

Estimate who responds, not just the average. Fit a family of meta-learners on top of any base regressor, pick the winner on a held-out validation slice, then rank units by predicted uplift and read the cumulative-gain (Qini) curve against random — the operational payoff.

1

Input · what goes in

An outcome Y, a binary treatment W, and features X — typically from an experiment or a de-confounded observational sample.

Show data format & exampleHide example

Format — one row per unit: outcome y, treatment flag w, features X.

from causalml.inference.meta import BaseXRegressor
from xgboost import XGBRegressor
learner = BaseXRegressor(XGBRegressor())
cate = learner.fit_predict(X, treatment=w, y=y)
2

Pipeline · the recipe ⑂ has parallel branches

↑ Click any step in the diagram to read its logic, code, assumptions & discussion.

1
Data prep

Outcome, treatment, features

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

Assemble Y, the treatment flag W, and features X. The estimand is the conditional uplift τ(x).

Formula
au(x)=\mathbb{E}[\,Y(1)-Y(0)\mid X{=}x\,]
Reads from the input data Feeds into the final output
Key code
# y outcome, w treatment (0/1), X features

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
2
Estimation

Fit a family of meta-learners

The core estimate — where the causal quantity itself is computed.

What happens here

S/T/X-learners build τ̂ from base outcome models; the R-learner targets it directly through a residualised loss (Robinson).

Formula
\hat au_R=\arg\min_ au extstyle\sum_iig[(Y_i-\hat m(X_i))-(W_i-\hat e(X_i))\, au(X_i)ig]^2
Reads from the input data Feeds into the final output
Key code
from causalml.inference.meta import (
    BaseSRegressor, BaseTRegressor, BaseXRegressor, BaseRRegressor)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
3
Heterogeneity

Compare learners; choose by validation

Heterogeneity — who is affected, and by how much, not just on average.

What happens here

There's no single best meta-learner — score CATE error and ATE recovery on held-out data and let the data choose.

Formula
\hat au^\star=\arg\min_{\hat au\in\{S,T,X,R\}}\ \mathbb{E}_{ ext{val}}ig[(\hat au(X)- au(X))^2ig]
Reads from the input data Feeds into the final output
Key code
from causalml.metrics import get_cumgain
# compare S/T/X/R on a validation split

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
4
Reporting

Targeting: uplift / Qini gain

Reporting — turn the numbers into a figure or table a reader can act on.

What happens here

Rank units by predicted uplift and read the cumulative gain (AUUC/Qini) versus random — the operational payoff of the model.

Formula
\mathrm{AUUC}=\int_0^1ig(g_{ ext{model}}(\phi)-g_{ ext{random}}(\phi)ig)\,d\phi
Reads from the input data Feeds into the final output
Key code
from causalml.metrics import plot_gain, auuc_score
plot_gain(df)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
3

Output · what you get 2 figures

CausalML benchmarks the S-, T-, X- and R-learners: CATE error (MSE) vs. ATE error, train vs. validation — pick the learner that generalises.
Fig 1CausalML benchmarks the S-, T-, X- and R-learners: CATE error (MSE) vs. ATE error, train vs. validation — pick the learner that generalises.
Uplift gain curve: targeting by the model captures far more cumulative effect than random allocation across the population.
Fig 2Uplift gain curve: targeting by the model captures far more cumulative effect than random allocation across the population.

Figures reproduced from CausalML — Uber (Chen, Harinen, Lee, Zhao et al.) — unofficial community showcase; all credit to the original authors.

⚠️ Unofficial community showcase of causalml. Not affiliated with the authors; all credit to them.

Estimate who responds, not just the average: fit a family of meta-learners for the CATE, pick the best by validation error, then rank and target with an uplift curve.

Discussion (2)

  • 2

    The 'no single best meta-learner, score on validation' framing is right. I've watched the X-learner win and lose on the same product.

  • 1

    The uplift gain curve over random is the plot that actually convinces ops. Saved.