Skip to content
svgsurv-brier-curve

Survival Brier score

How far are predicted survival probabilities from what happened, at each time?

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

How to read it

  1. Read each point as the squared error of the predicted survival probability at that time; lower is better.
  2. Compare with the dashed line at 0.25: the score of a forecast that always says 50%.
  3. Read the number at the top left, the integrated Brier score: the average of this curve across the times shown.
  1. Callout 1: Early on few events have happened, so errors are small for any model.
  2. Callout 2: Reference: a 50/50 forecast.
  3. Callout 3: Integrated Brier score.

Watch out

  • The curve tends to rise with time for any model as outcomes become less certain. Compare models at the same times, not early against late.
  • A low Brier score at a time when nearly everyone is alive can be earned by predicting survival for all.

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.
  • Rows with an event by t count (S(t))² over the chance of remaining uncensored until their event; rows still at risk count (1 − S(t))² over the same chance at t. The integrated score is the trapezoid mean over the times shown.
# Survival Brier score — Codesplash Chart Lab (recipe "surv-brier-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("surv-brier-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")
def trapezoid_mean(t, v):
    """The integrated Brier score: trapezoid area over the span of the times."""
    t, v = np.asarray(t, float), np.asarray(v, float)
    return float(np.sum(np.diff(t) * (v[1:] + v[:-1]) / 2) / (t[-1] - t[0])) if len(t) > 1 else float(v[0])
T = "Days since diagnosis"
B = "Brier score"
d = df.dropna(subset=[T, B]).sort_values(T)
fig, ax = plt.subplots(figsize=(7, 4))
ax.axhline(0.25, color=REF, linestyle="--", linewidth=1, label="0.25: a 50/50 forecast")
ax.plot(d[T], d[B], marker="o", markersize=3, color=PALETTE[0], label=f"integrated {trapezoid_mean(d[T], d[B]):.3f}")
ax.set_ylim(0, max(0.3, d[B].max()))
ax.set_xlabel(T)
ax.set_ylabel(B)
ax.legend(frameon=False)
plt.show()

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