Data Drift vs. Concept Drift: PSI, KS-Test & Production Model Monitoring
Why every deployed ML model silently decays over time, how to separate Covariate Shift from Concept Drift, and how PSI & KS-tests trigger retraining
Data Drift (Covariate Shift) happens when live input distributions P(X) change over time, while Concept Drift happens when the true relationship P(y|X) between inputs and outcomes changes — and ML Monitoring tracks both continuously in production.
Traditional software crashes loudly with 500 errors; ML models fail SILENTLY by returning confident wrong predictions while customer behavior or fraud tactics evolve.
Deploying a model is Day 1, not the finish line — unmonitored ML models degrade relentlessly as markets, users, and adversaries change.
Monitoring prediction distributions, null-rate spikes, and PSI catches broken upstream ETL pipelines within minutes instead of quarters.
Recognizing Concept Drift (e.g., COVID lockdowns changing travel patterns) tells you to weight recent data higher or retrain rather than blaming the model code.
Top MLOps interview question: 'How do you detect model degradation when ground-truth labels take 60 days to arrive?'
A spam filter was trained in 2022. In 2025, scammers start using brand-new AI-written phishing templates so emails that used to look legitimate (X) are now spam (y=1). What type of drift is this?
- Distinguish Data Drift (P(X) shifts), Label Drift (P(y) shifts), and Concept Drift (P(y|X) shifts) with concrete examples.
- Compute and interpret the Population Stability Index (PSI: <0.10 stable, 0.10–0.25 moderate, >0.25 severe drift).
- Monitor input drift immediately when ground-truth labels are delayed by weeks (e.g., 90-day loan defaults).
- Design safe automated retraining triggers paired with shadow/canary rollouts.
Think of ML monitoring as three concentric radar rings: (1) Data Health (null spikes, schema breaks), (2) Input & Prediction Drift (PSI / KS-test — works even when labels are delayed!), and (3) Ground-Truth Accuracy (live AUC/RMSE once labels arrive).
1. The 3 Types of Drift & How to Catch Them
| Drift Type | What Changed? | Detect Without Labels? | Example |
|---|---|---|---|
| Data Drift (Covariate Shift) | Yes (PSI, KS-test, Wasserstein) | Upstream bug changes USD to cents, or user demographics shift | |
| Prediction / Label Drift | or | Yes for | Sudden jump in predicted fraud rate from 2% to 18% |
| Concept Drift | No (needs delayed labels or proxy KPIs) | Fraudsters invent new attack patterns; consumer tastes shift |
The exact honest questions almost every beginner wonders — answered in plain English without hiding behind jargon.
Not always! If an unimportant feature drifted, accuracy might stay fine. Conversely, if a top SHAP feature shows PSI > 0.25, investigate immediately — it is almost always an upstream data bug or major market shift.
Activate All 5 Pillars of a Ship-Ready ML Project
import numpy as np
# Population Stability Index (PSI) From Scratch to Monitor Live Data Drift
def compute_psi(expected: np.ndarray, actual: np.ndarray, bins: int = 5) -> float:
edges = np.quantile(expected, np.linspace(0, 1, bins + 1))
edges[0], edges[-1] = -np.inf, np.inf
e_pct = np.histogram(expected, bins=edges)[0] / len(expected)
a_pct = np.histogram(actual, bins=edges)[0] / len(actual)
e_pct = np.clip(e_pct, 1e-6, 1.0)
a_pct = np.clip(a_pct, 1e-6, 1.0)
return float(np.sum((a_pct - e_pct) * np.log(a_pct / e_pct)))
rng = np.random.default_rng(0)
train_feat = rng.normal(50, 10, size=1000)
live_ok = rng.normal(50.5, 10, size=1000)
live_drift = rng.normal(62, 12, size=1000) # severe mean + spread shift!
print(f"Healthy live PSI: {compute_psi(train_feat, live_ok):.4f} (< 0.10 green)")
print(f"Drifted live PSI: {compute_psi(train_feat, live_drift):.4f} (> 0.25 RED ALERT!)")