Skip to content
svgtd-auc-curve

Time-dependent AUC

How well does a survival model rank who has the event by each time?

Demo data · seed 20261101 · 9 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read each point as one follow-up time: the chance that someone with the event by then was scored above someone still event-free.
  2. Compare with the dashed line at 0.5, where the score ranks no better than a coin flip.
  3. Follow the line across time: a falling line means the model ranks early events better than late ones.
  1. Callout 1: Early follow-up: how well the score ranks the first events.
  2. Callout 2: Dashed line: no skill.
  3. Callout 3: The plain mean over the times shown.

Watch out

  • Late times rest on few rows still under follow-up, so the right end of the line is the noisiest part.
  • A high AUC says the ranking is good, not that the predicted probabilities are right. Read the Brier curve for those.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Draws the run's numbers as given (computed by the host's cs-ml evaluation or the Python/R engine); the chart computes nothing statistical.
  • Cases are events up to t, weighted by the inverse probability of remaining uncensored (a reverse Kaplan–Meier of the scored rows); controls are rows still at risk after t. Ties in risk count ½. The dashed line at 0.5 is a model with no skill.
# Time-dependent AUC — Codesplash Chart Lab (recipe "td-auc-curve")
# 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("td-auc-curve-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"])  # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"])  # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
T = "Days since diagnosis"
A = "Time-dependent AUC"
d = df.dropna(subset=[T, A]).sort_values(T)
fig, ax = plt.subplots(figsize=(7, 4))
ax.axhline(0.5, color=REF, linestyle="--", linewidth=1, label="no skill")
ax.plot(d[T], d[A], marker="o", markersize=3, color=PALETTE[0], label=f"mean AUC {d[A].mean():.3f}")
ax.set_ylim(min(0.4, d[A].min()), 1)
ax.set_xlabel(T)
ax.set_ylabel(A)
ax.legend(frameon=False)
plt.show()

Needs pandas, numpy, matplotlib · reads td-auc-curve-demo.csv · app theme from the optional codesplash helper