Concept Drift and Delayed Labels
The data drift monitors compare today's inputs with the training inputs. They have a blind spot that is easy to state and expensive to forget: if the inputs stay the same but the answer for those inputs changes, every input statistic stays flat while the model gets worse. A lender's applicants look exactly as they did last year, but in a downturn the same debt ratio now leads to default more often. A fraud ring keeps the transaction amounts typical but moves to a new merchant pattern. To see that, you need the labels, and in production the labels arrive late, sometimes months late. This lesson is about that gap: what changes, why input monitors miss it, what you can watch while waiting for labels, and how to run an error-rate detector on labels that trickle in.
The detectors themselves (Page-Hinkley, DDM, ADWIN) are derived in Detecting Concept Drift, for online learners that see the label right after each prediction. Here they meet a deployed batch-trained model and a label delay.
What changes
With , concept drift is a change in : the decision boundary that was right is now in the wrong place. Input monitors estimate only, so a pure concept change, with fixed, is invisible to PSI, KS and chi-square by construction. The opposite also happens: inputs drift into a region where the model is still right, an input monitor fires, and nothing is wrong.
The only direct measure of is the model's error on labelled live data:
where the sum runs over the predictions of day whose labels have arrived. The rest of the lesson is about the two problems in that sentence: "have arrived" (delay) and "a daily rate is noisy" (a detector).
The lab: the same monitor, a different change
The drift-monitor lab again, with drift pattern "concept": from day 31 the labels follow instead of , while the inputs are drawn exactly as before. The model keeps predicting , so after day 31 every input between 0 and 0.5 is now more likely to be misclassified. Watch it with PSI first:
PSI stays near its noise level all the way through (0.090 on day 31, 0.064 on day 38, 0.106 on day 60) and never reaches 0.2: the readout says "missed". The histograms of reference and live data look the same because they are the same distribution. Meanwhile the status box shows the model's daily error rising, from 0.155 on day 30 to 0.175 on day 38 and 0.245 on day 60.
Now switch the statistic to Page-Hinkley on the daily error rate, threshold 0.3. Page-Hinkley accumulates how far each day's error lies above the running mean (minus a tolerance ) and alarms when that sum climbs more than the threshold above its minimum, as derived in the earlier lesson:
The statistic sits near zero for 30 days (0.010 on day 30), starts climbing after the change, reads 0.292 on day 37 and 0.308 on day 38: first alarm on day 38, a delay of 7 days, no false alarms. Seven days is the price of averaging out the noise of a daily error rate from 200 predictions. Lower the threshold to 0.1 and the alarm comes on day 33, but with 3 false alarms before the change (the first on day 12).
The lab assumes every label arrives the same day. In real systems the delay is added on top: if outcomes take 30 days, a detector with a 7-day detection delay raises its alarm about 37 days after the change.
The third view is the opposite case: a gradual covariate shift (inputs ramp from day 21 to day 40), watched on the error.
Page-Hinkley never fires, because the error does not go up: the inputs move away from the boundary at 0, where most mistakes happen, so the daily error falls (0.095 on day 40, 0.115 on day 60, against 0.145 on day 20). PSI on the same data does alarm, on day 38. Both monitors are right about what they measure. That is why production systems run both: input monitors as a fast, label-free early warning, and error monitors as the judge of whether the model is actually hurt.
Label delay
How long labels take depends on the problem:
| Problem | Label | Typical delay |
|---|---|---|
| Click or add-to-cart prediction | the click | seconds to minutes |
| Demand forecast | the sales of the day | a day |
| Fraud | a chargeback | weeks |
| Credit default | 90 days past due | months to a year |
| Medical outcome | follow-up | months to years |
Delay causes three problems beyond plain lateness:
- Partial labels are biased. The labels that arrive first are not a random sample: early defaults are a particular kind of default, and fraud reported quickly is the obvious fraud. A "label-complete" error rate needs the full maturity window; an early estimate must be read as a lower or upper bound, not as the rate.
- Some labels never arrive. A rejected loan applicant never shows whether they would have repaid. That is a feedback loop, covered in retraining strategies.
- The join must be possible. You can only compute if each prediction was logged with an id that the outcome later carries (monitoring covers the prediction log).
Proxies while you wait
Without labels you can still watch quantities that often move when the concept moves:
- The prediction distribution: the share of positive predictions, the mean score, a PSI on the score. It reacts to input drift and to changes in the features the model uses.
- Confidence: the mean top-class probability, or the share of predictions near the threshold. A model seeing unfamiliar inputs often becomes less confident.
- Fast partial labels and human feedback: early defaults, user complaints, manual review overrides, a small sample sent for labelling every day.
The first two are still functions of only, so a pure concept change leaves them flat too. The code below shows exactly that, and then the only thing that does catch it.
From scratch: proxies versus the error
The lab's setup, 120 days with 500 predictions per day and a concept change on day 61. The model outputs a probability and predicts positive above 0.5. The code prints, per 20-day block, the input mean, two proxies and the label-based error rate.
import numpy as np
rng = np.random.default_rng(0)
days, n, t_change = 120, 500, 61
rows = []
for d in range(1, days + 1):
x = rng.normal(0, 1, n) # inputs never change
b = 0.5 if d >= t_change else 0.0 # the label rule does
y = (x + 0.5 * rng.normal(0, 1, n) > b).astype(int)
p = 1 / (1 + np.exp(-3 * x)) # model score
y_hat = (p > 0.5).astype(int)
conf = np.maximum(p, 1 - p) # top-class probability
rows.append((x.mean(), y_hat.mean(), conf.mean(), (y_hat != y).mean()))
rows = np.array(rows)
print("days input mean positive rate mean confidence error rate")
for a in range(0, days, 20):
m = rows[a:a + 20].mean(axis=0)
print(f"{a + 1:3d}-{a + 20:3d} {m[0]:+.3f} {m[1]:.3f} {m[2]:.3f} {m[3]:.3f}")days input mean positive rate mean confidence error rate
1- 20 +0.006 0.501 0.839 0.146
21- 40 -0.004 0.495 0.837 0.152
41- 60 -0.009 0.502 0.838 0.142
61- 80 +0.003 0.499 0.835 0.202
81-100 +0.001 0.496 0.836 0.203
101-120 +0.002 0.503 0.835 0.212
Before and after day 61 the input mean stays within 0.01 of zero, the positive prediction rate stays at about 0.50 and the mean confidence at about 0.836 to 0.839. A dashboard of label-free signals is flat. The error rate is the only column that moves, from 0.142 to 0.152 in the first three blocks to 0.202 to 0.212 in the last three. A model whose score is a function of cannot notice from its own outputs that the meaning of changed.
A detector on delayed labels
Now the labels arrive days after the prediction. Each calendar day, the monitor receives the labels of day , computes that day's error rate and feeds it to Page-Hinkley (, threshold 0.3, as in the lab). The question is on which calendar day the alarm goes off, and how many predictions were made on the new concept by then.
import numpy as np
class PageHinkley:
"""Alarm when the mean of the input rises (see ml-training-strategies/concept-drift)."""
def __init__(self, delta=0.005, lam=0.3):
self.delta, self.lam = delta, lam
self.n, self.mean, self.m, self.m_min = 0, 0.0, 0.0, 0.0
def update(self, x):
self.n += 1
self.mean += (x - self.mean) / self.n
self.m += x - self.mean - self.delta
self.m_min = min(self.m_min, self.m)
return self.m - self.m_min > self.lam
rng = np.random.default_rng(0)
days, n, t_change = 120, 500, 61
err = np.empty(days + 1)
for d in range(1, days + 1):
x = rng.normal(0, 1, n)
b = 0.5 if d >= t_change else 0.0
y = (x + 0.5 * rng.normal(0, 1, n) > b).astype(int)
err[d] = ((x > 0).astype(int) != y).mean()
for delay in (0, 7, 30):
ph, alarm = PageHinkley(), None
for today in range(1, days + 1):
label_day = today - delay # labels of this day arrive today
if label_day >= 1 and ph.update(err[label_day]):
alarm = (today, label_day)
break
today, label_day = alarm
served = (today - t_change + 1) * n
print(f"label delay {delay:2d} d: alarm on calendar day {today:3d} "
f"(labels of day {label_day}), {served} predictions on the new concept by then")label delay 0 d: alarm on calendar day 66 (labels of day 66), 3000 predictions on the new concept by then
label delay 7 d: alarm on calendar day 73 (labels of day 66), 6500 predictions on the new concept by then
label delay 30 d: alarm on calendar day 96 (labels of day 66), 18000 predictions on the new concept by then
The detector itself is identical in all three runs: it fires on the labels of day 66, five days after the change. Only the calendar moves. With same-day labels the alarm comes on day 66, after 3,000 predictions on the new concept; with a 7-day delay on day 73 (6,500); with a 30-day delay on day 96, after 18,000 predictions made with the old rule. For a model with slow labels, the detection delay that matters is label delay plus detector delay, and the faster proxies above, a small daily labelling sample, or early partial labels are worth their cost.
Pitfalls
- Monitoring only inputs. Input monitors are cheap and fast, and blind to the change that hurts most. Budget for labels: even a small random sample labelled every day gives an unbiased error estimate.
- Comparing immature with mature periods. If last month's labels are 60 % complete and the reference month's are 100 % complete, the error rates are not comparable. Compare cohorts at the same label age ("error after 30 days" for both).
- A detector without a reaction. An alarm should lead somewhere: a ticket with a runbook, a retraining job, a rollback. Retraining strategies covers triggered retraining.
- Recurring concepts. If the concept flips with the seasons, keep the old models: a registry of past versions lets you switch back instead of relearning.
- Thresholds tuned on one incident. Set the detector threshold on historical stable periods (false alarm rate) and on replayed past drifts (delay), the same trade-off as in the earlier lesson.
Practice
- In the second lab, increase the live window from 200 to 500 with threshold 0.3. Does the alarm come earlier or later, and why?
- A fraud model's chargebacks arrive after 45 days on average, but 30 % of the confirmed fraud is reported by customers within 2 days. How would you build a fast monitor from that, and what is its bias?
- Why did the gradual shift in the third lab lower the error, and would that also happen if the inputs moved towards the boundary instead?
Answers
- Earlier: with seed 1 the first alarm moves from day 38 (delay 7) to day 36 (delay 5), still with no false alarms. With 500 predictions per day the daily error rate is less noisy, so the rise after day 31 stands out sooner against the running mean. Less noise also allows a lower threshold: at , threshold 0.1 alarms on day 32 (delay 1) with no false alarms, where gave 3.
- Track the error (or the fraud rate among flagged and unflagged transactions) on the fast reports only, with its own baseline computed from the same fast reports in a stable past period. It is biased towards fraud that customers notice quickly, so it can miss a new kind of quiet fraud, but compared with its own baseline it detects changes in the fast-reported part weeks earlier. Confirm with the 45-day labels.
- The model is wrong mostly near its boundary , where noise flips the label. Moving the inputs away (the mean goes to 0.5) puts fewer of them near the boundary, so fewer mistakes. If the inputs moved towards the boundary, more points would be ambiguous and the error would rise even though did not change.
Test yourself
In the lab with concept drift from day 31, PSI on the input never alarmed. Why?
- The threshold was too high
- The window was too small
- The input distribution did not change at all; only did
- PSI needs more bins
Page-Hinkley on the daily error with threshold 0.3 alarmed on day 38 for a change on day 31. If labels take 30 days to arrive, when would the alarm be raised?
- Day 38
- About day 68
- Day 31
- Never
Which proxy can detect a pure concept change, with inputs unchanged?
- The positive prediction rate
- The mean confidence
- PSI on the model score
- None of these; you need (some) labels
Why is an error rate computed from the first labels to arrive often biased?
- Labels are random
- The early labels are a particular kind of case (early defaults, obvious fraud), not a random sample
- Error rates are always biased
- Because of the epsilon in PSI