Production ML
Advanced 15 min read Production ML

Data & Concept Drift

The world moved; the model didn't

Data drift is the input distribution moving away from training; concept drift is the mapping from inputs to labels changing. Both break models silently. Detection ranges from simple tests to adaptive systems, but the operational question is always 'what do we do when drift is real?'

data driftconcept driftcovariate shiftPSIKS testADWINretraining triggerwindow
Before we start

What you will learn

  • Distinguish data drift, covariate shift and concept drift
  • Choose detection methods (PSI, KS, chi-square) and windows
  • Turn drift signals into concrete operational actions
Introduction

What is this?

Data drift means the input distribution the model sees differs from training (e.g., feature 'account age' shifted). Covariate shift is the cleanest version: P(x) changes, P(y|x) stays. Concept drift means the relationship itself changed: the same features now map to different outcomes (a spending pattern that used to be normal is now fraud). Drift is not an error state by itself — it is the earliest reliable warning that the model's edge is moving, and must be filtered from 'benign seasonal change' before triggering retraining.

Motivation

Why do you need it?

  • Drift is the leading indicator: quality drops later, users feel it first.
  • Confusing the two types sends you fixing the wrong thing (retraining a model when the target changed policy-wise).
  • Statistical 'drift' on shift-vs-noise is how you avoid retraining storms on benign seasons.
  • Knowing which features drifted tells you whether to retrain, add data, or redesign the feature.
Think about it

Mental model

Imagine

A weather forecast tuned to a coastal climate

Think of

Data & concept drift

If you move the forecast inland (data drift), the same typical-temp model now predicts badly — P(weather) changed. If the region's seasons flip (concept drift), even identical summer conditions now mean different storms — P(outcome|conditions) changed. Both require a new forecast, but the fix is different: more local data versus learning a new relationship.

Mechanics

How it works

  • Window the inputs: training/reference distribution vs rolling production window (day, week).
  • Measure per feature: PSI (population stability index), KS test, chi-square for categoricals, or model-based detectors.
  • Detect concept drift: compare expected vs observed outcomes on a delayed-label cohort; use adaptive window algorithms (ADWIN) for streaming data.
  • Filter: separate real structural drift from seasonal/benign shifts using business context and calendar windows.
  • Act: retrain trigger, data-collection gap fill, feature-space expansion, or a decision-threshold recalibration.

From signal to decision: drift detection flow.

Reference vs live
Per-feature tests
Filter benign shifts
Concept check
Act
Real world

In production

  • A loan-approval model tracks PSI per feature weekly; when 'income' shifts > 0.25 PSI, a data-collection task starts before retraining (the shift is often a real economic change, not an error).
  • A churn model uses a KS test on a 7-day window; each detector is paired with a runbook — 'field maintenance', 'promo war', 'retrain'.
  • An anomaly system uses ADWIN to adapt windows online so concept drift updates its baseline instead of drowning in false peaks.
Guidelines

Best practices

  • Detect per feature AND on the joint/prediction — one changed feature can be noise; the prediction distribution rarely lies.
  • Pair every detector with a decision rule and owner; an alert without an action is decoration.
  • Reconcile drift with true labels later: drift + confirmed concept change validates retraining triggers.
  • Benchmark drift indicators against known historical incidents so thresholds encode real events.
  • Use calendar-and-quantile windows to make seasonality expected, not an alert.
Watch out

Common mistakes

  • Retraining on every drift alert without asking whether the shift is benign, real, or a pipeline bug.
  • Treating data drift and concept drift identically when their fixes differ (more data vs new model vs recalibrate).
  • Alerting on z-score per feature with no multiple-comparison guard — with 50 features, noise trips alerts constantly.
  • Measuring drift on processed features the model sees, missing breakage upstream in raw data.
Root cause analysis

Common issues

Error
Drift alert fires every Friday
Root cause

Weekly batch shipping the weekend's data — benign cyclic shift

Fix

Add calendar-week baseline windows and quantile normalization; alert on cycle-relative change.

Error
No drift alert, but quality collapsed
Root cause

Concept drift invisible to input-distribution tests

Fix

Add delayed-label outcome comparison (expected vs observed y by cohort).

Error
Retrained model still fails after drift alert
Root cause

Drift was a pipeline/data-integrity break, not a distribution shift

Fix

Diff raw vs feature pipelines and validate data quality upstream before retraining.

When things break

Debugging tips

  • Look at drift per feature vs drift in predictions: if features shifted but predictions didn't, the model is robust or ignoring them — check both.
  • Confirm the drift is in raw data, not a pipeline bug (e.g., a field mapping change) before opening a retrain ticket.
  • On concept drift, examine label-policy/game changes (fraudsters adapt, incentives change) before blaming the model.
  • Backdate a detector's output vs known incidents to validate its sensitivity before relying on it.
Interviews

Interview checkpoint

Practice

Hands-on lab

Detect Data Drift with PSI & KS
30 min · advanced
In progress
Objectives
  • Compute Population Stability Index (PSI) and KS between reference and live feature distributions
  • Judge real shift vs benign noise with thresholds
  • Couple drift to a data-versus-context classification decision

Detect Data Drift with PSI & KS

30 min · advanced

0/5 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

Concept drift is best described as:

2

Every statistically significant drift should trigger an immediate retrain.

Go deeper

Official documentation