S / T / X / R Meta-Learners: A Beginner's Guide to Estimating Individual Causal Effects
*Getting the books straight for every user — how the four meta-learners work, their temperaments, and how to choose* (a causal inference tutorial from zhichai.net, ~25 min read)
Contents
1. Opening story: should Zhang San get the promo? 2. Two potential outcomes: Y(0) and Y(1) 3. Three invisible ghosts: confounding, selection bias, heterogeneous effects 4. Assumptions shared by all four learners 5. S-Learner: one model for everyone 6. T-Learner: two models, two mouths 7. X-Learner: using the T-Learner in reverse 8. R-Learner: Robinson's residualization magic 9. Decision guide and code with causalml 10. Limitations
The Problem
A marketer has 20,000 users, budget to message half of them, and asks: *for each individual user*, how much extra revenue would the SMS generate? Standard tools fail:
- A classifier predicting "did messaged users buy?" is invalid — non-messaged users never got the chance.
- An A/B test gives only the average effect, hiding who should be targeted.
- Naive regression with treatment as a feature yields correlation, not causation (messaged users may simply be more active).
- Confounding: e.g., high activity drives both spending and receiving promotions, creating spurious correlation between T and Y.
- Selection bias: non-random assignment (marketers cherry-picking targets) makes treated and control groups differ before treatment.
- Heterogeneous treatment effects (HTE): the same promo may help loyal customers and annoy new ones; CATE exists precisely to capture this.
- Pros: simplest to implement and debug; stable when T correlates strongly with X and the base model has weak regularization.
- Cons: regularized models (XGBoost, Lasso) tend to discount the binary T feature, shrinking τ̂(x) toward zero; each x is only ever observed with one t, so predictions are extrapolations.
- Pros: no regularization discrimination against T; each arm can use its own model; intuitive and explainable.
- Cons: each model sees only half the data (higher variance); if the arms' covariate distributions barely overlap, both models extrapolate independently and tail predictions become unreliable.
- D̃₁ᵢ = Y(1)ᵢ − μ̂₀(Xᵢ) for treated units i (the control model imagines their untreated outcome),
- D̃₀ⱼ = μ̂₁(Xⱼ) − Y(0)ⱼ for control units j. 3. Fit effect models τ̂₁(x) and τ̂₀(x) on D̃₁ and D̃₀, then blend: τ̂(x) = g(x)·τ̂₁(x) + (1 − g(x))·τ̂₀(x), where g(x) is the propensity score (weighting toward the larger arm).
- Pros: rescues extremely imbalanced settings — the imputed effects for the small arm leverage the large arm's well-fit model; lower variance in overlap regions than the T-Learner.
- Cons: the imputed effects are counterfactuals that inherit errors from step 1; large variance when overlap is poor.
What we want is the Conditional Average Treatment Effect:
τ(x) = E[ Y(1) − Y(0) | X = x ]
Terminology: T is the binary treatment (send SMS or not), Y the outcome (weekly spend), X user covariates, and τ(x) the per-user causal effect.
Potential Outcomes and the Fundamental Problem
Under the Rubin Causal Model, each person has two potential outcomes, Y(0) and Y(1), but only one is ever observed. If Zhang San receives the SMS you see Y(1) = 150; his Y(0) = 100 remains an unobservable counterfactual. All meta-learners are strategies for inferring this missing half using other people's data.
Three Challenges
Key assumptions shared by all meta-learners:
1. Unconfoundedness: given X, treatment is independent of potential outcomes. If important confounders are unobserved, you need design-based methods (IV, DiD, RDD) instead. 2. SUTVA / no spillover: treating one user does not affect others. 3. Overlap: for every x, both treated and control samples exist.
S-Learner (Single)
Fit one model μ(x, t) = E[Y | X = x, T = t] with T as an ordinary feature, then τ̂(x) = μ̂(x,1) − μ̂(x,0).
Use when: very large data, strong T–X correlation, and a base model without strong regularization.
T-Learner (Two)
Fit separate models μ̂₀(x) on controls and μ̂₁(x) on treated; estimate τ̂(x) = μ̂₁(x) − μ̂₀(x).
Use when: both arms have ample samples with reasonable overlap. Avoid when the treated group is tiny (e.g., < 1,000).
X-Learner (Künzel et al., 2017)
Designed for highly imbalanced arms (e.g., 100 treated vs. 900 control). Three steps:
1. Fit μ̂₀ and μ̂₁ as in the T-Learner. 2. Build *imputed individual effects*:
R-Learner (Robinson, 1988)
Starts from the partially linear model Y = m(X) + τ(X)·T + ε. Robinson's identity residualizes both sides using the propensity score e(x) = P(T=1 | X=x):
(Y − m(X)) = τ(X) · (T − e(X)) + noise correction
Two steps: (1) fit nuisance models for m(X) and e(X) (ideally via cross-fitting), then (2) fit τ(x) as the slope relating the outcome residuals to the treatment residuals. Unlike S/T/X, the R-Learner directly targets the effect rather than the outcome expectation, which often yields better finite-sample behavior for heterogeneous effects.
Choosing a Learner
| Situation | Recommendation | |---|---| | Huge data, weakly regularized base model | S-Learner | | Both arms large, good overlap | T-Learner | | Treated arm much smaller (≤ ~10%) | X-Learner | | Strong heterogeneity, want direct effect modeling | R-Learner |
Implementations for all four are available in Uber's open-source causalml library, e.g. BaseSClassifier/BaseSRegressor, BaseTRegressor, BaseXRegressor, and BaseRRegressor.
Limitations
All four learners assume unconfoundedness. If key confounders are unobserved (e.g., a user's current mood), no meta-learner can save you — you need design-based identification strategies such as instrumental variables, difference-in-differences, or regression discontinuity.
*Note: the source post was truncated during retrieval; the code-walkthrough sections referenced in its table of contents are summarized above from the surrounding text.*