Worked examples — Data drift and concept drift detection
Before we start, one word we'll use constantly: a bin is a bucket. We chop a numeric feature's range into a few intervals (say "0–20 years old", "20–40", "40+") and count how many data points land in each. The proportion of a bin is (points in that bin) ÷ (total points). All the and symbols below are just these proportions — reference vs current.
The scenario matrix
Every drift computation you'll ever do is one of these cells. The worked examples that follow are tagged with the cell they cover.
| # | Case class | What's tricky | Example |
|---|---|---|---|
| A | No drift () | Must return exactly 0 | Ex 1 |
| B | Mass shifts up in one bin () | Sign check on log-ratio | Ex 2 |
| C | Mass shifts down () | Term still positive | Ex 2 |
| D | Zero-count bin ( or ) | — degenerate! | Ex 3 |
| E | Continuous shift, KS | Where is the max gap? | Ex 4 (figure) |
| F | Categorical mix, chi-square | Observed vs expected counts | Ex 5 |
| G | Concept drift alarm (DDM) | 2σ vs 3σ crossing | Ex 6 (figure) |
| H | Limiting behaviour | PSI as bins → identical/opposite | Ex 7 |
| I | Real-world word problem | Which test? which fix? | Ex 8 |
| J | Exam twist — data drift but NO accuracy loss | Don't retrain reflexively | Ex 9 |
We use these tools from the parent: PSI/KL, the KS statistic, chi-square, and DDM.
Example 1 — Cell A: the no-drift baseline
Example 2 — Cells B & C: one bin up, one bin down
Example 3 — Cell D: the zero-count degenerate case
Example 4 — Cell E: KS statistic, finding the max gap
Reference , current . Find the KS statistic .
Forecast: the current is the reference shifted +2. Where do the step-CDFs separate most?

The empirical CDF is just "what fraction of my sample is ." It's a staircase that steps up by at each data point.
- Build : steps at , each . So as passes each point. Why this step? KS compares the two staircases; we need their heights.
- Build : steps at . , but just before 3 it is .
- Scan for the biggest vertical gap . Evaluate at each reference point:
- At : , → gap .
- At : , → gap .
- At (just after): , → gap . Why this step? "" means the worst-case gap; on staircases the max always occurs at a jump point, so we only check those.
- .
Verify: A pure +2 shift of a 5-point sample leaves of points "unmatched" at the extreme, i.e. gap . Matches. Large ⇒ KS flags a clear right-shift. ✓
Example 5 — Cell F: chi-square on a categorical feature
Reference proportions over {Card, Cash, Wallet} . Current window has transactions, observed counts . Compute .
Forecast: if nothing shifted we'd expect . How far off are we?
- Expected counts . Why this step? compares what we saw against what the reference proportions predict at this sample size.
- Per-category :
- Card:
- Cash:
- Wallet: Why this step? Squaring makes every deviation positive; dividing by scales it — a gap of 10 matters more for a rare category than a common one.
- .
Verify: Degrees of freedom . The critical value at for df is . Our ⇒ reject "same mix" → categorical drift detected. Sanity: , as it must (both sum to 200). ✓
Example 6 — Cell G: DDM concept-drift alarm
During good performance DDM recorded a running minimum with . A new batch of predictions has error rate . Is it Warning, Drift, or fine?
Forecast: is noise, or has the retrain trigger fired?

- Current spread . Why this step? Each prediction is right/wrong — a Bernoulli. The error rate over of them wobbles with the standard deviation of a proportion. We need this wobble to know if is "far".
- The statistic: . Why this step? DDM tracks the pessimistic edge (rate plus its own noise), not just the rate.
- Warning threshold: . Is ? Yes → past Warning.
- Drift threshold: . Is ? Yes → DRIFT. Why 3σ? If errors were just noise around , exceeding 3 standard deviations is a ~0.1% event — too rare to be luck. So we call it real degradation and trigger retraining.
Verify: , so both thresholds are crossed → Drift state (the stronger). Consistent: a jump from 10% to ~18% pessimistic error is well beyond 3σ. ✓
Example 7 — Cell H: limiting behaviour of PSI
(a) Distributions become identical: , . (b) Distributions become maximally opposite (with smoothing): , .
Forecast: what's the smallest possible PSI? Does the largest blow up?
- (a) Identical limit: every → PSI . This is the floor. Why this step? Confirms the lower bound — PSI can't go negative (proved via Jensen's inequality in the parent).
- (b) Opposite limit: Bin 1: . Bin 2: . PSI . Why this step? As one bin empties toward 0, its term drives PSI toward — there is no upper bound. That's why PSI needs thresholds (0.1, 0.25), not a max-scale normalization.
Verify: (a) hits the theoretical minimum 0; (b) matches Example 3's 4.604 (same numbers) — PSI is unbounded above. The 0.25 "significant" line sits far below this ceiling, which is why real drift comfortably clears it. ✓
Example 8 — Cell I: real-world word problem
Your fraud model scores transactions live. Fraud labels arrive 60 days late (chargebacks). This week, the transaction-amount distribution PSI jumped to , but you have no fresh labels. What's happening, and what do you do?
Forecast: is this data drift, concept drift, or can't-tell-yet? Which lever do you pull?
- Identify the factor. PSI on (amounts) → input distribution moved = data drift confirmed. Why this step? PSI only sees ; it says nothing about whether the rule changed. See covariate shift.
- Can we see concept drift now? No — DDM needs , and labels are 60 days out (label delay). Why this step? Concept drift is invisible until error can be measured. Don't pretend the PSI alarm is concept drift.
- Use a proxy. Monitor the model's output-score distribution and predicted-fraud rate. If the fraud-flag rate spikes far beyond history, that's a proxy concept-drift signal. Why this step? When labels lag, prediction distributions are the only live signal (shadow a candidate model too).
- Decide. Data drift alone → watch + reweight, don't retrain blindly. Set a delayed-label evaluation to fire in 60 days; if error then exceeds the DDM 3σ line, retrain.
Verify: Decision chain is internally consistent: (drift level) but the action is bounded by what we can measure. We did not trigger a costly retrain on covariate shift alone — matching the parent's steel-manned mistake #1. ✓
Example 9 — Cell J: exam twist (drift without accuracy loss)
Feature age shows PSI (significant). But shadow-evaluated accuracy on this week's labelled sample is unchanged at 0.94, same as training. Do you retrain?
Forecast: the PSI alarm is red. Is that enough?
- Read both signals. PSI high → moved (data drift). Accuracy flat → intact → no concept drift. Why this step? Recall . Only the factor moved. If the model already generalizes to the new age region, predictions stay correct.
- Cost–benefit. Retraining costs compute, review, and risk. A stable-accuracy covariate shift doesn't justify it yet. Why this step? "Statistical significance ≠ practical harm." The 0.28 PSI is real but harmless here.
- Action: Do not retrain. Keep monitoring — if accuracy later dips (concept drift arrives), then trigger via the pipeline.
Verify: Accuracy (unchanged) is the decisive metric; PSI is context. Correct answer: monitor, don't retrain. This is exactly why the parent warns "data drift always means retrain" is a fallacy. ✓
Active recall
Cover the answers first.
Every empty bin makes raw PSI equal to what value, and what's the fix?
On staircase (empirical) CDFs, the KS max gap always occurs where?
In chi-square, comes from where?
DDM's Drift threshold is which multiple of above ?
If PSI is high but shadow accuracy is unchanged, do you retrain?
Recall Scenario-matrix self-quiz
- Which cell is " danger"? (Answer: D) 2. Which two cells prove PSI terms stay positive whether mass leaves or arrives? (B and C) 3. Which cell shows PSI has no upper bound? (H) 4. Which cell fires the 3σ retrain trigger? (G)
"Zero, Sup, Sigma."
- Zero bin → -smooth (Cell D).
- Sup for KS → check jump points only (Cell E).
- Sigma for DDM → 2 warns, 3 retrains (Cell G).
Connections
- Parent topic
- Model Monitoring in Production
- Retraining Pipelines and Triggers
- KL Divergence and Cross-Entropy
- Kolmogorov-Smirnov Test
- Covariate Shift and Importance Weighting
- Feature Stores and Reference Windows
- A-B Testing and Shadow Deployment
- Class Imbalance and Label Delay