svgbrier-over-time
Brier score over time
Are a deployed model's probabilities still trustworthy?
How to read it
- Read the line as the Brier score per period: lower is better.
- Compare with the dashed level at deployment.
- A sustained rise means predicted probabilities are drifting away from reality.
- Callout 1: Rising above the deployment level.
- Callout 2: Dashed line: the level at deployment.
Watch out
- The score depends on the event rate: a seasonal rate change can move it without any model decay.
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.
- Brier score = mean squared difference between the predicted probability of the positive class and the outcome (0/1); lower is better.
# Brier score over time — Codesplash Chart Lab (recipe "brier-over-time")
# 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("brier-over-time-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["week"] = pd.to_datetime(df["week"])
_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 = "week"
B = "Brier score"
BASE = "at deployment"
d = df.dropna(subset=[T, B]).sort_values(T)
fig, ax = plt.subplots(figsize=(7, 4))
ax.plot(d[T], d[B], marker="o", markersize=3, color=PALETTE[0], label="Brier score")
if BASE and d[BASE].notna().any():
ax.axhline(d[BASE].dropna().iloc[0], color=REF, linestyle="--", linewidth=1, label="at deployment")
ax.set_ylim(bottom=0)
ax.set_xlabel(T)
ax.set_ylabel("Brier score")
ax.legend(fontsize=8)
plt.show()Needs pandas, numpy, matplotlib · reads brier-over-time-demo.csv · app theme from the optional codesplash helper
# Brier score over time — Codesplash Chart Lab (recipe "brier-over-time")
# 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("brier-over-time-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["week"] = pd.to_datetime(df["week"])
_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 = "week"
B = "Brier score"
BASE = "at deployment"
d = df.dropna(subset=[T, B]).sort_values(T)
fig = go.Figure()
fig.add_scatter(x=d[T], y=d[B], mode="lines+markers", line=dict(color=PALETTE[0]), name="Brier score")
if BASE and d[BASE].notna().any():
fig.add_hline(y=float(d[BASE].dropna().iloc[0]), line_dash="dash", line_color=REF)
fig.update_layout(xaxis_title=T, yaxis_title="Brier score", yaxis_rangemode="tozero")
fig.show()Needs pandas, numpy, plotly · reads brier-over-time-demo.csv · app theme from the optional codesplash helper
# Brier score over time — Codesplash Chart Lab (recipe "brier-over-time")
# 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("brier-over-time-demo.csv", check.names = FALSE, stringsAsFactors = FALSE, na.strings = "") # empty cells are missing; Chart Lab → Code → Download demo CSV
df[["week"]] <- as.POSIXct(df[["week"]], tz = "UTC")
tok <- if (has_cs) codesplashr::cs_palette(dark = FALSE) else list()
seq_ramp <- if (is.null(tok$sequential)) c("#eff6fd", "#1a469d") else tok$sequential # low → high
div_ramp <- if (is.null(tok$diverging)) c("#c13e2e", "#f3f5f8", "#0859ac") else tok$diverging # −, 0, +
ref_col <- if (is.null(tok$reference)) "#4e5661" else tok$reference
grey_col <- if (is.null(tok$dim)) "#ced1d6" else tok$dim
T <- "week"
B <- "Brier score"
BASE <- "at deployment"
d <- data.frame(t = df[[T]], b = df[[B]])
d <- d[!is.na(d$t) & is.finite(d$b), ]
base <- if (is.null(BASE)) NA else df[[BASE]][which(is.finite(df[[BASE]]))[1]]
p <- ggplot(d, aes(t, b)) +
(if (is.finite(base)) geom_hline(yintercept = base, colour = ref_col, linetype = "dashed")) +
geom_line(colour = cs_cat[[1]]) + geom_point(colour = cs_cat[[1]], size = 1) +
expand_limits(y = 0) +
labs(x = T, y = "Brier score") + theme_cs
print(p)Needs ggplot2 · reads brier-over-time-demo.csv · app theme from the optional codesplashr helper