Skip to content
svgdrift-timeline

Drift over time

Which features of the scoring data are drifting away from the training data, and since when?

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

How to read it

  1. Read each line as one feature's drift statistic over scoring runs.
  2. Compare with the alert threshold.
  3. A sudden rise suggests a data change; a slow rise, gradual drift.
  1. Callout 1: This feature crossed the alert threshold.
  2. Callout 2: The threshold.
  3. Callout 3: The stable features.

Watch out

  • Input drift doesn't always hurt the model. Check performance too.

Defaults

Alert threshold (null = none)
0.25
Draw a line at the level that should raise an alert.
Range 0 to 1,000,000, step 0.01

Pinned in the code

  • Draws the run's numbers as given (computed by the Python/R engine); the chart computes nothing statistical.
  • The six features with the largest value keep a colour; others are grey. PSI rule of thumb: < 0.1 stable, 0.1–0.25 moderate, > 0.25 major shift (the default alert).
# Drift over time — Codesplash Chart Lab (recipe "drift-timeline")
# controls: threshold=0.25
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"]
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
SERIES_DASHES = ["-", (0, (6, 3)), (0, (1.5, 2.5)), (0, (8, 3, 2, 3)), (0, (12, 4)), (0, (3, 3)), (0, (8, 2, 2, 2, 2, 2)), (0, (1.5, 5))]

df = pd.read_csv("drift-timeline-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["scoring week"] = pd.to_datetime(df["scoring week"])

T = "scoring week"
V = "PSI"
F = "feature"
THRESHOLD = 0.25
d = df.dropna(subset=[T, V]).sort_values(T)
top = d.groupby(F, observed=True)[V].max().sort_values(ascending=False).index[:6]
fig, ax = plt.subplots(figsize=(8, 4.5))
for name, g in d.groupby(F, observed=True):
    k = list(top).index(name) if name in top else None
    ax.plot(g[T], g[V], color=PALETTE[k] if k is not None else "grey", alpha=1 if k is not None else 0.45, linewidth=1.8 if k is not None else 1,
            linestyle=SERIES_DASHES[k] if k is not None else "-", label=str(name) if k is not None else None)  # highlighted features also differ by dash, as in the app
if THRESHOLD is not None:
    ax.axhline(THRESHOLD, color="#ce5342", linestyle="--", linewidth=1)
    hot = d[d[V] > THRESHOLD]
    ax.scatter(hot[T], hot[V], color="#ce5342", s=16, zorder=3)
ax.set_xlabel(T)
ax.set_ylabel(V)
ax.legend(fontsize=8)
plt.show()

Needs pandas, numpy, matplotlib · reads drift-timeline-demo.csv · app theme from the optional codesplash helper