Skip to content

CCausal inference · causal.uplift

Uplift evaluation (Qini, AUUC, RATE)

Does a targeting score find the units whose outcome the treatment changes most?

Evaluates an uplift (CATE) score on randomized data — or with a known treatment probability: the Qini curve and Qini coefficient, the uplift curve and AUUC, the uplift in the top 10/20/30% of the ranking, and the rank-weighted average treatment effect (RATE: AUTOC or Qini weighting, grf's estimator with inverse-probability scores) with a bootstrap interval. A score that ranks well has a positive RATE: targeting by it beats treating at random.

Verified in Python and R Python and R agree to 10 decimals Seeded

A real result

Example “Informative score”, recorded in both engines. In the app, “Try this example” loads it into Analyze.

Uplift evaluation of uplift_scoreRecorded · Python and R agreeRecorded 2026-11-17 · 23 values compared
R

Ranking by uplift_score, the AUTOC rank-weighted treatment effect is 0.06 (95% CI [0.01, 0.11], p = .018). The top 10% of the ranking shows an uplift of 0.12 against an average effect of −0.01; the Qini coefficient is 0.0074.

RATE (AUTOC)
0.0594
95% CI
[0.0102, 0.1085]
p
.018
Qini coefficient
0.0074
AUUC
0.0120

Assumptions

  • Randomized treatment — Assumes treatment was randomized with probability 0.501; with confounded treatment use doubly robust scores instead.
  • Score ranks effects — Targeting by the score beats random targeting (the RATE interval excludes 0).

Uplift in the top of the ranking

Top share targetedUplift (treated − control)
10%0.1200
20%0.0779
30%0.0416
All (ATE)−0.0053
  • RATE standard error from 200 bootstrap resamples (seed 42); curves computed over tied scores as blocks.
Python

Ranking by uplift_score, the AUTOC rank-weighted treatment effect is 0.06 (95% CI [0.01, 0.11], p = .018). The top 10% of the ranking shows an uplift of 0.12 against an average effect of −0.01; the Qini coefficient is 0.0074.

RATE (AUTOC)
0.0594
95% CI
[0.0102, 0.1085]
p
.018
Qini coefficient
0.0074
AUUC
0.0120

Assumptions

  • Randomized treatment — Assumes treatment was randomized with probability 0.501; with confounded treatment use doubly robust scores instead.
  • Score ranks effects — Targeting by the score beats random targeting (the RATE interval excludes 0).

Uplift in the top of the ranking

Top share targetedUplift (treated − control)
10%0.1200
20%0.0779
30%0.0416
All (ATE)−0.0053
  • RATE standard error from 200 bootstrap resamples (seed 42); curves computed over tied scores as blocks.

Shortened for the Academy: 1 chart(s) dropped to stay under 100 KB; 1 chart(s) dropped to stay under 100 KB.

Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.

Worked examples in the app

  • Informative scorec2_uplift · outcome: converted · score: uplift_score · treatment: offer
  • Random score qinic2_uplift · outcome: converted · score: random_score · treatment: offer
  • Spend known propensityc2_uplift · outcome: spend · score: uplift_score · treatment: offer
  • Degenerate constantc2_uplift · outcome: converted · score: uplift_score · treatment: offer
  • Degenerate n3c2_uplift · outcome: converted · score: uplift_score · treatment: offer

In the guides

Where it sits in the decision guides

  • Causal ML (uplift modeling) · DS & ML Decision Guide · Explain — why is it happening?

What you need

Outcomenumeric / boolean · 1 column
The outcome the treatment may affect (a number, or yes/no).
Treatment (randomized)boolean / categorical · 1 column · 2–2 levels
Which rows were randomly assigned to treatment. Uplift needs randomized assignment.
Uplift scorenumeric · 1 column
Predicted benefit of treatment per row (higher = target first), e.g. a CATE from a causal forest or meta-learner.

Choices you make

hypothesis

Treated groupdefault —

Default: the second stored level (true for yes/no columns).

Probability of treatmentdefault —

The randomization probability; by default the share of treated rows.

Confidence leveldefault 0.95

How sure the intervals should be: 0.95 gives 95% confidence intervals. Higher confidence means wider intervals.

statistics

RATE weightingdefault AUTOC

How the ranking of individual effects is scored: AUTOC stresses the top of the list; Qini stresses overall gains.

  • AUTOC (emphasizes the top of the ranking)(default) — Weights the top of the ranking most; pick it when only a few can be treated.
  • Qini (emphasizes overall gains) — Weights gains more evenly across the ranking; pick it when many can be treated.
Bootstrap resamplesdefault 200

Number of bootstrap resamples. More gives steadier intervals but takes longer; use 1,000 or more for reporting.

Checks and remedies

CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.

  • Randomized treatment

    The curves compare treated and control rows within each slice of the ranking, which is fair only when treatment was randomized (or its probability is known).

  • Score fitted on other dataNot checked from data: state why it holds

    Evaluate a score on rows it was not trained on.

  • Score ranks effects

    Targeting by the score should beat random targeting (the RATE interval excludes 0).

What it reports

  • Tests: Rank-weighted average treatment effect
estimate
How much the outcome changes for a one-unit change in a predictor, holding the others fixed.
se
The typical size of the error in an estimate, the standard deviation of its sampling distribution.
ci_low
A range of effect values compatible with your data at the chosen confidence level.
ci_high
A range of effect values compatible with your data at the chosen confidence level.
z
An estimate in standard-error units, compared with the standard normal distribution.
p_value
How surprising your data would be if the null hypothesis were true, as a probability.
n
How many independent units the analysis used; it sets precision and power.
n_treated
How many independent units the analysis used; it sets precision and power.
n_control
How many independent units the analysis used; it sets precision and power.
propensity
Each unit's probability of treatment given its covariates; used to match or weight comparable groups.
ate
The average effect if everyone were treated versus no one.
qini_coefficient
How much a treatment changes the outcome for a unit, compared with leaving it untreated.
auuc
How much a treatment changes the outcome for a unit, compared with leaving it untreated.
auuc_random
How much a treatment changes the outcome for a unit, compared with leaving it untreated.
uplift_top_10
How much a treatment changes the outcome for a unit, compared with leaving it untreated.
uplift_top_20
How much a treatment changes the outcome for a unit, compared with leaving it untreated.
uplift_top_30
How much a treatment changes the outcome for a unit, compared with leaving it untreated.
target
How the ranking is scored: AUTOC stresses the top of the ranking, QINI weights gains more evenly across it.
estimand
The exact quantity an analysis targets, such as a difference in means or a ratio of medians.
effect_label
Which group counts as first (or treated, or positive) decides the sign of differences and ratios on the card.
claim_level_max
How strong a causal statement the design supports, from association up to a causal effect.
treated_level
Which group counts as first (or treated, or positive) decides the sign of differences and ratios on the card.
control_level
Which group counts as first (or treated, or positive) decides the sign of differences and ratios on the card.

Python and R

Python and R agree to 10 decimals (relative tolerance 1e-9). Python uses pandas, numpy, scipy, codesplash; R uses stats, nanoparquet, codesplashr.

Default traps between the two languages

  • Both engines run the twins codesplash.causal.uplift ↔ cs_causal_uplift_* / cs_causal_rate: sklift's qini/uplift curve definitions over tie blocks and grf's RATE point estimate (rank_average_treatment_effect.fit with IPW scores). The interval comes from a row bootstrap on the portable Wichmann–Hill stream; grf's own half-sample bootstrap uses a different RNG.
Python

The exact script CodeSplash ran for example “Informative score” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0

# Uplift evaluation (Qini, AUUC, RATE)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method causal.uplift 1.0.2 · spec 76ee2df503c4fb8e
# Dataset: c2_uplift (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.causal import uplift as csu
from codesplash.causal import weighting as csw

# %% Data
df = pd.read_parquet("tests/parity/fixtures/c2_uplift.parquet", columns=["converted", "offer", "uplift_score"])
n_input = len(df)
df["converted"] = pd.Categorical(df["converted"], categories=["false", "true"])  # stored level order
df["offer"] = pd.Categorical(df["offer"], categories=["false", "true"])  # stored level order
df = df.dropna(subset=["converted", "offer", "uplift_score"])  # listwise deletion over the analysis columns
df["converted"] = df["converted"].cat.remove_unused_categories()
df["offer"] = df["offer"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["converted", "offer", "uplift_score"])  # infinite values stop the run (registry/errors.yaml)

# %% Treatment, outcome and score
treatment = "offer"
outcome = "converted"
score_col = "uplift_score"
conf = 0.95
seed = 42  # portable Wichmann–Hill stream: R draws the same bootstrap resamples
t, treated_level, control_level = csw.treatment_indicator(df, treatment, None)
y, event_level = csw.outcome_vector(df, outcome)
score = df[score_col].to_numpy(dtype=float)
if np.unique(score).size < 2:  # a constant score ranks nobody: every curve is the random line
    cs.cs_error("CS_E_CONSTANT", column=score_col)
n = len(t)
n_treated, n_control = int(t.sum()), int(n - t.sum())
outcome_text = f"{outcome} = {event_level}" if event_level is not None else outcome
p_opt = None
p = float(t.mean()) if p_opt is None else float(p_opt)
target = "AUTOC"  # AUTOC | QINI
B = int(200)

# %% Curves and RATE (sklift curve definitions; grf's RATE estimator with IPW scores)
cur = csu.curves(y, t, score)
gamma = csu.ipw_scores(y, t, p)
rate = csu.rate(gamma, score, target)
boot = csu.rate_bootstrap(y, t, score, p_opt, target, B, seed)
boot = boot[~np.isnan(boot)]
se = float(np.std(boot, ddof=1))
ci_low, ci_high, p_value = csu.normal_ci(rate, se, conf)
ate = float(y[t == 1].mean() - y[t == 0].mean())
tops = {q: csu.uplift_at(y, t, score, q / 100) for q in (10, 20, 30)}

# %% Checks
checks = [{"id": "randomization", "label": "Randomized treatment", "status": "info",
           "detail": f"Assumes treatment was randomized with probability {p:.3f}; with confounded treatment use doubly robust scores instead."},
          {"id": "ranking", "label": "Score ranks effects", "status": "pass" if ci_low > 0 else "concern",
           "detail": ("Targeting by the score beats random targeting (the RATE interval excludes 0)." if ci_low > 0
                      else "The RATE interval includes 0: the score may not rank treatment effects better than chance.")}]

# %% Result
effect_label = f"Rank-weighted average treatment effect ({target}) of targeting {treatment} = {treated_level} by {score_col} on {outcome_text}"
pct = f"{conf:.0%}"
summary = (
    f"Ranking by {score_col}, the {target} rank-weighted treatment effect is {cs.fmt_num(rate)} ({pct} CI [{cs.fmt_num(ci_low)}, "
    f"{cs.fmt_num(ci_high)}], {cs.fmt_p(p_value)}). The top 10% of the ranking shows an uplift of "
    f"{cs.fmt_num(tops[10]) if tops[10] is not None else '—'} against an average effect of {cs.fmt_num(ate)}; the Qini coefficient is "
    f"{cur['qini_coefficient']:.4f}."
)
values = {
    "estimate": rate, "se": se, "ci_low": ci_low, "ci_high": ci_high, "z": rate / se if se > 0 else None, "p_value": p_value,
    "n": n, "n_treated": n_treated, "n_control": n_control, "propensity": p, "ate": ate,
    "qini_coefficient": cur["qini_coefficient"], "auuc": cur["auuc"], "auuc_random": cur["auuc_random"],
    "uplift_top_10": tops[10], "uplift_top_20": tops[20], "uplift_top_30": tops[30], "target": target,
    "estimand": f"RATE ({target})", "effect_label": effect_label, "claim_level_max": "L4",
    "treated_level": treated_level, "control_level": control_level,
}
x = list(cur["x"])
cs.publish({
    "method": "causal.uplift",
    "methodVersion": "1.0.2",
    "title": f"Uplift evaluation of {score_col}",
    "engine": cs.engine_info("numpy", "pandas", "scipy"),
    "n": n,
    "summary": summary,
    "statistics": [
        {"key": "estimate", "label": f"RATE ({target})", "value": rate},
        {"key": "ci", "label": f"{pct} CI", "value": [ci_low, ci_high]},
        {"key": "p_value", "label": "p", "value": p_value, "format": "p"},
        {"key": "qini_coefficient", "label": "Qini coefficient", "value": cur["qini_coefficient"]},
        {"key": "auuc", "label": "AUUC", "value": cur["auuc"]},
    ],
    "tables": [{"key": "top", "title": "Uplift in the top of the ranking", "columns": [
        {"key": "share", "label": "Top share targeted", "type": "string"}, {"key": "uplift", "label": "Uplift (treated − control)", "type": "number"}],
        "rows": [{"share": f"{q}%", "uplift": tops[q]} for q in (10, 20, 30)] + [{"share": "All (ATE)", "uplift": ate}]}],
    "assumptions": [{"key": c["id"], "label": c["label"], "status": {"concern": "warn"}.get(c["status"], c["status"]), "detail": c["detail"]} for c in checks],
    "checks": checks,
    "warnings": warnings,
    "notes": [f"RATE standard error from {boot.size} bootstrap resamples (seed {seed}); curves computed over tied scores as blocks."],
    "charts": [cs.chart(
        "qini", "qini-curve", "Qini curve",
        {"fraction": cs.col("Share targeted", x + x),
         "gain": cs.col("Incremental outcomes", list(cur["qini"]) + list(cur["random_qini"])),
         "curve": cs.col("Curve", ["model"] * len(x) + ["random"] * len(x), kind="categorical")},
    )],
    "values": values,
})
R

The exact script CodeSplash ran for example “Informative score” · R version 4.5.1 (2025-06-13)

# Uplift evaluation (Qini, AUUC, RATE)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method causal.uplift 1.0.2 · spec 76ee2df503c4fb8e
# Dataset: c2_uplift (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/c2_uplift.parquet", col_select = c("converted", "offer", "uplift_score")))
n_input <- nrow(df)
df[["converted"]] <- factor(df[["converted"]], levels = c("false", "true"))  # stored level order
df[["offer"]] <- factor(df[["offer"]], levels = c("false", "true"))  # stored level order
df <- df[stats::complete.cases(df[c("converted", "offer", "uplift_score")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("converted", "offer", "uplift_score"))  # infinite values stop the run (registry/errors.yaml)

# %% Treatment, outcome and score
treatment <- "offer"
outcome <- "converted"
score_col <- "uplift_score"
conf <- 0.95
seed <- 42  # portable Wichmann–Hill stream: Python draws the same bootstrap resamples
tr_info <- cs_causal_treatment(df, treatment, NULL)
t <- tr_info$t
treated_level <- tr_info$treated
control_level <- tr_info$control
y_info <- cs_causal_outcome(df, outcome)
y <- y_info$y
event_level <- y_info$event
score <- as.numeric(df[[score_col]])
if (length(unique(score)) < 2) cs_error("CS_E_CONSTANT", column = score_col)  # a constant score ranks nobody: every curve is the random line
n <- length(t)
n_treated <- as.integer(sum(t))
n_control <- as.integer(n - sum(t))
outcome_text <- if (!is.null(event_level)) sprintf("%s = %s", outcome, event_level) else outcome
p_opt <- NULL
p <- if (is.null(p_opt)) mean(t) else as.numeric(p_opt)
target <- "AUTOC"  # AUTOC | QINI
B <- as.integer(200)

# %% Curves and RATE (point estimate = grf::rank_average_treatment_effect.fit(DR.scores = IPW scores, priorities = score)$estimate)
cur <- cs_causal_uplift_curves(y, t, score)
gamma <- cs_causal_ipw_scores(y, t, p)
rate <- cs_causal_rate(gamma, score, target)
boot <- cs_causal_rate_bootstrap(y, t, score, p_opt, target, B, seed)
boot <- boot[!is.na(boot)]
se <- stats::sd(boot)
zc <- stats::qnorm(1 - (1 - conf) / 2)
ci_low <- rate - zc * se
ci_high <- rate + zc * se
p_value <- if (se > 0) 2 * stats::pnorm(abs(rate / se), lower.tail = FALSE) else NaN
ate <- mean(y[t == 1]) - mean(y[t == 0])
tops <- lapply(c(10, 20, 30), function(q) cs_causal_uplift_at(y, t, score, q / 100))

# %% Checks
checks <- list(
  list(id = "randomization", label = "Randomized treatment", status = "info",
       detail = sprintf("Assumes treatment was randomized with probability %.3f; with confounded treatment use doubly robust scores instead.", p)),
  list(id = "ranking", label = "Score ranks effects", status = if (ci_low > 0) "pass" else "concern",
       detail = if (ci_low > 0) "Targeting by the score beats random targeting (the RATE interval excludes 0)."
                else "The RATE interval includes 0: the score may not rank treatment effects better than chance."))

# %% Result
effect_label <- sprintf("Rank-weighted average treatment effect (%s) of targeting %s = %s by %s on %s", target, treatment, treated_level, score_col, outcome_text)
pct <- sprintf("%.0f%%", conf * 100)
summary <- paste0(
  sprintf("Ranking by %s, the %s rank-weighted treatment effect is %s (%s CI [%s, %s], %s). ", score_col, target, cs_fmt_num(rate), pct,
          cs_fmt_num(ci_low), cs_fmt_num(ci_high), cs_fmt_p(p_value)),
  sprintf("The top 10%% of the ranking shows an uplift of %s against an average effect of %s; the Qini coefficient is %.4f.",
          if (!is.null(tops[[1]])) cs_fmt_num(tops[[1]]) else "—", cs_fmt_num(ate), cur$qini_coefficient))
values <- list(estimate = rate, se = se, ci_low = ci_low, ci_high = ci_high, z = if (se > 0) rate / se else NULL, p_value = p_value,
               n = n, n_treated = n_treated, n_control = n_control, propensity = p, ate = ate,
               qini_coefficient = cur$qini_coefficient, auuc = cur$auuc, auuc_random = cur$auuc_random)
values["uplift_top_10"] <- list(tops[[1]])
values["uplift_top_20"] <- list(tops[[2]])
values["uplift_top_30"] <- list(tops[[3]])
values <- c(values, list(target = target, estimand = sprintf("RATE (%s)", target), effect_label = effect_label, claim_level_max = "L4",
                         treated_level = treated_level, control_level = control_level))
x <- cur$x
cs_publish(list(
  method = "causal.uplift",
  methodVersion = "1.0.2",
  title = sprintf("Uplift evaluation of %s", score_col),
  engine = cs_engine_info("stats", "nanoparquet"),
  n = n,
  summary = summary,
  statistics = list(
    list(key = "estimate", label = sprintf("RATE (%s)", target), value = rate),
    list(key = "ci", label = paste(pct, "CI"), value = c(ci_low, ci_high)),
    list(key = "p_value", label = "p", value = p_value, format = "p"),
    list(key = "qini_coefficient", label = "Qini coefficient", value = cur$qini_coefficient),
    list(key = "auuc", label = "AUUC", value = cur$auuc)),
  tables = list(list(key = "top", title = "Uplift in the top of the ranking", columns = list(
    list(key = "share", label = "Top share targeted", type = "string"), list(key = "uplift", label = "Uplift (treated − control)", type = "number")),
    rows = c(lapply(1:3, function(i) list(share = sprintf("%d%%", c(10, 20, 30)[i]), uplift = tops[[i]])), list(list(share = "All (ATE)", uplift = ate))))),
  assumptions = lapply(checks, function(c) list(key = c$id, label = c$label, status = if (c$status == "concern") "warn" else c$status, detail = c$detail)),
  checks = checks,
  warnings = warnings,
  notes = list(sprintf("RATE standard error from %d bootstrap resamples (seed %d); curves computed over tied scores as blocks.", length(boot), seed)),
  charts = list(cs_chart("qini", "qini-curve", "Qini curve", list(
    fraction = cs_col("Share targeted", c(x, x)),
    gain = cs_col("Incremental outcomes", c(cur$qini, cur$random_qini)),
    curve = cs_col("Curve", c(rep("model", length(x)), rep("random", length(x))), kind = "categorical")))),
  values = values
))

Sources

  • Radcliffe, N. J. (2007). Using control groups to target on predicted lift. Direct Marketing Analytics Journal, 1, 14–21.
  • Yadlowsky, S., Fleming, S., Shah, N., Brunskill, E., & Wager, S. (2023). Evaluating treatment prioritization rules via rank-weighted average treatment effects. JASA.
  • Gutierrez, P., & Gérardy, J.-Y. (2017). Causal inference and uplift modelling: A review of the literature. PMLR 67, 1–13.

From the CodeSplash method registry · causal.uplift v1.0.2.