svgcumulative-lift
Cumulative lift
Is the treatment effect stable over the test, or fading (novelty) or growing (primacy)?
How to read it
- Read the line as cumulative lift since launch.
- Early values swing widely, then settle.
- A steady fall may be novelty; a steady climb, primacy.
- Callout 1: Early: wide, unstable.
- Callout 2: Settled lift.
- Callout 3: The band still crosses zero.
Watch out
- Peeking at this chart and stopping when it looks good inflates false positives.
Defaults
No settings: the chart draws one way.
Pinned in the code
- Draws the run's numbers as given (computed by the Python/R engine); the chart computes nothing statistical.
- Each point is the lift on all data up to that time (not the daily lift), so bands narrow as data accumulate; early wide swings are expected.
- A trend after the band has narrowed suggests novelty or primacy effects — compare by days since first exposure, which the engine reports as a separate breakdown.
# Cumulative lift — Codesplash Chart Lab (recipe "cumulative-lift")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]
df = pd.read_csv("cumulative-lift-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["metric"] = pd.Categorical(df["metric"].astype("string"), categories=["conversion", "revenue per user"])
def levels_of(s):
"""Declared level order (categoricals), else order of first appearance."""
if isinstance(s.dtype, pd.CategoricalDtype):
return [v for v in s.cat.categories if (s == v).any()]
return list(dict.fromkeys(s.dropna().astype(str)))
X = "day since launch"
Y = "cumulative relative lift"
LO = "ci_low"
HI = "ci_high"
G = "metric"
groups = levels_of(df[G]) if G else [None]
series = []
for name in groups:
d = df if name is None else df[df[G].astype(str) == str(name)]
series.append((name if name is not None else "", d.dropna(subset=[X]).sort_values(X)))
fig, ax = plt.subplots(figsize=(8, 4.5))
ax.axhline(0, color="grey", linewidth=0.8)
for i, (name, d) in enumerate(series):
col = PALETTE[i % len(PALETTE)]
if LO and HI:
ax.fill_between(d[X], d[LO], d[HI], color=col, alpha=0.15, lw=0)
ax.plot(d[X], d[Y], color=col, linewidth=2, label=name or Y)
ax.set_xlabel(X)
ax.set_ylabel(Y)
if G: ax.legend(fontsize=8)
plt.show()Needs pandas, numpy, matplotlib · reads cumulative-lift-demo.csv · app theme from the optional codesplash helper
# Cumulative lift — Codesplash Chart Lab (recipe "cumulative-lift")
# controls: defaults
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else px.colors.qualitative.Plotly
df = pd.read_csv("cumulative-lift-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["metric"] = pd.Categorical(df["metric"].astype("string"), categories=["conversion", "revenue per user"])
def levels_of(s):
"""Declared level order (categoricals), else order of first appearance."""
if isinstance(s.dtype, pd.CategoricalDtype):
return [v for v in s.cat.categories if (s == v).any()]
return list(dict.fromkeys(s.dropna().astype(str)))
def rgba(hex_colour, alpha):
h = hex_colour.lstrip("#")
return f"rgba({int(h[0:2], 16)}, {int(h[2:4], 16)}, {int(h[4:6], 16)}, {alpha})"
X = "day since launch"
Y = "cumulative relative lift"
LO = "ci_low"
HI = "ci_high"
G = "metric"
groups = levels_of(df[G]) if G else [None]
series = []
for name in groups:
d = df if name is None else df[df[G].astype(str) == str(name)]
series.append((name if name is not None else "", d.dropna(subset=[X]).sort_values(X)))
fig = go.Figure()
for i, (name, d) in enumerate(series):
col = PALETTE[i % len(PALETTE)]
shape = "linear"
if LO and HI:
fig.add_scatter(x=d[X], y=d[LO], mode="lines", line=dict(width=0, shape=shape), showlegend=False, hoverinfo="skip")
fig.add_scatter(x=d[X], y=d[HI], mode="lines", line=dict(width=0, shape=shape), fill="tonexty", fillcolor=rgba(col, 0.15), showlegend=False, hoverinfo="skip")
fig.add_scatter(x=d[X], y=d[Y], mode="lines", name=name or Y, line=dict(color=col, width=2, shape=shape))
fig.add_hline(y=0, line=dict(color="grey", width=1))
fig.update_layout(xaxis_title=X, yaxis_title=Y)
fig.show()Needs pandas, numpy, plotly · reads cumulative-lift-demo.csv · app theme from the optional codesplash helper
# Cumulative lift — Codesplash Chart Lab (recipe "cumulative-lift")
# controls: defaults
library(ggplot2)
has_cs <- isTRUE(requireNamespace("codesplashr", quietly = TRUE)) # optional: the app's chart theme
theme_cs <- if (has_cs) codesplashr::theme_codesplash(dark = FALSE) else theme_minimal()
cs_cat <- if (has_cs) codesplashr::cs_palette(dark = FALSE)$categorical else grDevices::palette.colors(8, "Okabe-Ito")
if (has_cs) update_geom_defaults("text", list(colour = codesplashr::cs_palette(dark = FALSE)$foreground))
df <- read.csv("cumulative-lift-demo.csv", check.names = FALSE, stringsAsFactors = FALSE, na.strings = "") # empty cells are missing; Chart Lab → Code → Download demo CSV
df[["metric"]] <- factor(df[["metric"]], levels = c("conversion", "revenue per user"))
levels_of <- function(v) if (is.factor(v)) levels(droplevels(v)) else unique(as.character(v[!is.na(v)]))
x_col <- "day since launch"
y_col <- "cumulative relative lift"
lo_col <- "ci_low"
hi_col <- "ci_high"
g_col <- "metric"
d <- data.frame(x = df[[x_col]], y = df[[y_col]], g = if (is.null(g_col)) "" else factor(as.character(df[[g_col]]), levels = levels_of(df[[g_col]])))
d$lo <- if (is.null(lo_col)) NA_real_ else df[[lo_col]]
d$hi <- if (is.null(hi_col)) NA_real_ else df[[hi_col]]
d <- d[!is.na(d$x) & !is.na(d$y), ]
d <- d[order(d$g, d$x), ]
p <- ggplot(d, aes(x, y, colour = g, fill = g)) +
geom_hline(yintercept = 0, colour = "grey50") +
{ if (!all(is.na(d$lo))) geom_ribbon(aes(ymin = lo, ymax = hi), colour = NA, alpha = 0.15) } + geom_line(linewidth = 0.9) +
scale_colour_manual(values = cs_cat, guide = if (is.null(g_col)) "none" else "legend") + scale_fill_manual(values = cs_cat, guide = "none") +
labs(x = x_col, y = y_col, colour = NULL) + theme_cs
print(p)Needs ggplot2 · reads cumulative-lift-demo.csv · app theme from the optional codesplashr helper