Targeting Discounts with Causal ML on Logged Data
Machine LearningModel answerLast updated
Design a causal ML pipeline that learns who should receive a standing promotion from observational logs, covering estimators, overlap, off-policy evaluation, fairness and a safe rollout.
A product has run a discount that is effectively always available to users. You only have historical logs, with no randomized experiment. For each user you observe pre-exposure features, whether they received the discount, and the revenue that followed. The business wants to spend the discount only where it creates extra revenue.
Describe an end-to-end causal ML approach that estimates how the discount effect varies across users and turns those estimates into a targeting rule. Your answer should cover:
- Estimator choice. Compare S-, T-, X- and DR-learners. Justify your pick using bias-variance trade-offs and the assumption that the logged assignment is unconfounded given the features.
- Modeling details. Which models do you use for the nuisance functions and for the final effect model? How does cross-fitting reduce overfitting and nuisance-induced bias?
- Overlap problems. How do you detect and handle poor overlap, extreme propensity scores, and deterministic eligibility rules?
- Evaluation. Which metrics would you use (policy value, uplift or Qini curves, a proxy for effect-estimation error)? How do you implement off-policy evaluation with inverse propensity weighting and doubly robust estimators?
- Fairness. Suppose the policy must satisfy demographic parity in who gets treated. How is that enforced, and what does it cost in value?
- Safe rollout. How would you test the learned policy online before deploying it fully?
State your assumptions explicitly, and mention the pitfalls you would watch for.
Hints
Hint 1
Start with the potential-outcomes setup: what is the effect function, what is the optimal rule when treating costs money, and which three assumptions (unconfoundedness, overlap, no interference) let you identify it from logs?
Hint 2
A pseudo-outcome that combines outcome-model predictions with an inverse-propensity-weighted residual is orthogonal to nuisance errors. Fit the nuisances on other folds so each user's pseudo-outcome is not contaminated by their own data.
Hint 3
You cannot observe individual effects, so evaluate with quantities that can be estimated: doubly robust policy value, cumulative uplift of top-ranked users, and calibration by score bin. For rollout, think holdout, ramp-up, and guardrail metrics.
Hint 4
Parity of treatment rates can be achieved with group-specific cutoffs on the net benefit score. Quantify the value you give up by comparing constrained and unconstrained policies on the same evaluation folds.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Setup and identification
Use potential outcomes. For features X, treatment T ∈ {0,1} (got the discount) and revenue Y, the target is the conditional average treatment effect τ(x) = E[Y(1) − Y(0) | X = x]. With a per-user cost c(x), the value-maximizing rule is treat if τ(x) > c(x). Under a fixed budget, treat the top-k users by τ̂(x) − c(x).
Identification from logs needs:
- Unconfoundedness: given X, assignment is independent of potential outcomes. Every driver of who was treated (eligibility rules, prior engagement, channel, timing) must be in X.
- Overlap: 0 < e(x) = P(T=1 | X=x) < 1.
- No interference between users.
An always-on discount tends to violate overlap (nearly everyone treated, or deterministic eligibility), so I would raise this first.
(a) Choosing a learner
| Learner | Idea | Weakness |
|---|---|---|
| S | One model f(x,t); τ̂ = f(x,1) − f(x,0) | Regularization can ignore T and shrink τ̂ toward 0 |
| T | Separate models per arm | Errors from two models add; poor when arms are imbalanced |
| X | Impute individual effects across arms, blend with e(x) | Good under imbalance, but only moderately robust to confounding |
| DR | Regress an AIPW pseudo-outcome on X | Variance blows up when e(x) is near 0 or 1 |
The DR pseudo-outcome is
φ = μ̂₁(X) − μ̂₀(X) + T(Y − μ̂₁(X))/ê(X) − (1−T)(Y − μ̂₀(X))/(1−ê(X)).
My choice: DR-learner (R-learner as a close alternative), with an X-learner as a benchmark. Because assignment is confounded, I want an orthogonal estimator: the bias scales with the product of propensity error and outcome error, so moderately accurate nuisances still give good CATE estimates. The cost is variance under weak overlap, handled in (c).
Revenue is heavy-tailed and zero-inflated. Winsorize at a high percentile (for example p99.5) for training, but report decisions on raw revenue since transformations change the estimand.
(b) Models and cross-fitting
- Propensity: gradient-boosted classifier, then calibrated (isotonic or Platt). Calibration matters more than AUC because ê is used as a weight.
- Outcomes: GBMs with a Tweedie or hurdle-style loss.
- Features: pre-treatment only. Post-exposure variables introduce post-treatment bias.
- Cross-fitting (K=5): for each fold, fit nuisances on the other folds and compute φ on the held-out fold. Then fit the final model on all out-of-fold φ. This stops a nuisance model's overfit to a row from leaking into that row's pseudo-outcome. Split by user, and use time-ordered splits if behavior drifts.
- Final stage: a shallow regularized GBM, a penalized linear model, or an honest causal forest if you want confidence intervals.
- Tuning: nuisances on their own predictive loss, the CATE model on held-out DR or R-loss rather than outcome accuracy.
(c) Overlap and extreme propensities
Diagnose: histograms of ê by arm, standardized mean differences after weighting (target < 0.1), and effective sample size (Σw)²/Σw².
Remedies:
- Trim to ê ∈ [α, 1−α] with α around 0.05–0.1. The learned policy is then valid only inside the overlap region; outside it, keep the status quo.
- Clip or self-normalize weights, trading a little bias for much lower variance.
- Overlap weights e(1−e) are good for model comparison but target a different population than the one you will act on.
- Deterministic eligibility cannot be fixed by reweighting. Use a regression discontinuity at the threshold if one exists, or collect randomized data. A permanent 1–5% random holdout is the best long-term fix and yields known propensities.
(d) Evaluation
Always evaluate on data not used to fit the policy. The policy value is V(π) = E[Y(π(X))] − E[c·π(X)].
- IPW: V̂ = (1/n) Σ 1{Tᵢ = π(Xᵢ)} Yᵢ / p̂(Tᵢ | Xᵢ). Prefer the self-normalized form.
- Doubly robust: V̂ = (1/n) Σ [ μ̂_{π(Xᵢ)}(Xᵢ) + 1{Tᵢ = π(Xᵢ)}(Yᵢ − μ̂_{Tᵢ}(Xᵢ)) / p̂(Tᵢ | Xᵢ) ]. It is consistent if either the propensity or the outcome model is right, and usually has lower variance.
- Intervals: from the influence-function terms or a user-level bootstrap.
- Baselines: treat-all, treat-none, and random targeting at equal budget.
Uplift/Qini: rank by τ̂; for each top-q fraction, estimate cumulative incremental revenue by summing DR pseudo-outcomes (or treated-minus-control differences on randomized data). Summarize with AUUC or the Qini coefficient versus random. The curve also shows where marginal uplift drops below cost.
PEHE proxy: true PEHE is unobservable. Use held-out DR-loss or R-loss to rank candidate models, plus calibration plots (bin by τ̂, compare the mean τ̂ with the DR-estimated average effect in each bin). Semi-synthetic benchmarks with known τ can validate the pipeline.
(e) Fairness
Demographic parity of treatment means P(π=1 | A=a) is equal across groups. With treatment rate q, the optimal constrained policy treats the top-q fraction by τ̂ − c within each group, which means group-specific thresholds (equivalently, a Lagrangian with a per-group shift).
The value can only stay equal or drop. Report the "price of fairness": V̂_DR(unconstrained) − V̂_DR(constrained), with intervals. Caveats: parity of treatment is not parity of outcomes; if protected attributes are not allowed as inputs, group thresholds may need proxies or post-processing, which has legal implications; and small groups give noisy thresholds.
(f) Safe online testing
- Offline gate: require DR value significantly above the current policy and acceptable calibration.
- Randomized experiment: assign users at random to the new policy, the current policy, and optionally a no-promo holdout. Randomize at the user level (or cluster, if there is interference).
- Metrics: primary is net incremental revenue after discount cost. Guardrails include conversion, retention, margin, complaints and fairness metrics by group.
- Ramp-up: 1% → 5% → 25% → 50%, with predefined stop rules and sequential or always-valid inference to allow monitoring without inflating false positives.
- Exploration: keep an epsilon of randomization in the deployed policy so you retain known propensities and can retrain.
- After launch: keep a long-term holdout to detect novelty effects, drift and decay.
Common mistakes
- Using post-treatment features.
- Skipping cross-fitting and trusting in-sample uplift.
- Evaluating a policy with the same data that trained it.
- Ignoring overlap, so a few huge weights dominate the estimates.
- Tuning for outcome accuracy instead of effect accuracy.
- Treating the CATE ranking as proof of value without checking cost and calibration.