Sub topic 3
Monitoring When Labels Are Late or Missing
Assume basic Python, NumPy, statistics, and model deployment. Production monitoring must still work when the true outcome arrives days or weeks after a prediction.
Delayed labels and proxy signals
Log each prediction with its timestamp, model version, input checks, score, decision, and an identifier that can later join to the true label. When labels arrive, calculate performance by time window and important subgroups.
Before labels arrive, use proxy signals:
- Monitor prediction rates and score distributions.
- Track user actions, complaints, manual reviews, or downstream failures.
- Compare short-term proxies with later labels to measure how trustworthy they are.
- Keep a separate “unknown” state. Missing labels are not negative labels.
A proxy can detect a problem, but it cannot prove that accuracy fell. Wait for confirmed labels before changing the model when the cost of a wrong change is high.
When drift matters
Drift matters when it changes decisions, harms performance, or violates a business constraint. A changed feature distribution may be harmless if the model is stable in the affected region. Conversely, performance can degrade without obvious feature drift when the relationship between inputs and outcomes changes.
Compare drift alerts with delayed performance, business outcomes, and data-quality results. Investigate the affected population, not only the overall average.
Multivariate drift with a domain classifier
Univariate tests inspect one feature at a time. A domain classifier tests whether several features together can distinguish reference rows from current rows.
Combine reference and current rows, label them by window, and train a classifier. A cross-validated ROC AUC near 0.5 suggests that the windows are hard to distinguish. A higher AUC indicates joint distribution shift, but not necessarily model failure.
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import cross_val_score
rng = np.random.default_rng(0)
reference = rng.normal(0, 1, (2000, 3))
current = rng.normal(0, 1, (2000, 3))
current[:, 0] += 0.5
X = np.vstack([reference, current])
y = np.r_[np.zeros(len(reference)), np.ones(len(current))]
auc = cross_val_score(
RandomForestClassifier(n_estimators=100, random_state=0),
X, y, cv=5, scoring="roc_auc"
).mean()
print(f"domain AUC={auc:.3f}")Thresholds and false alarms
Set thresholds using historical, stable data. Measure the alert rate and choose a level that matches the investigation capacity and business risk. Require persistence across windows, minimum sample sizes, or agreement between multiple signals. Record thresholds by feature and model version.
Responding to drift
Use a staged response:
| Evidence | Action |
|---|---|
| One weak drift signal | Investigate data and pipeline changes |
| Persistent drift with stable performance | Continue monitoring |
| Drift and confirmed performance loss | Retrain and validate |
| Severe loss or unsafe predictions | Roll back or disable the model |
Retraining requires representative, correctly labeled data. Rollback requires a tested fallback. Document the decision and monitor the replacement.
Exercise
A feature’s distribution shifts, but delayed labels show unchanged accuracy. What should you do?
Show answer
Investigate the cause and continue monitoring; do not retrain solely because of the drift signal.