Find out whether a running model is still useful
A production model can return fast, valid responses while becoming less useful. Monitoring must therefore look beyond server uptime to the data arriving, the predictions produced, and the real outcomes that may arrive days or months later.
Drift means a distribution changed. It is a clue, not a verdict. A seasonal customer mix can drift while model quality remains acceptable; a stable-looking aggregate can hide severe decay for one region or device.
What You Will Be Able to Explain
- Monitor service, data, predictions, and outcomes separately
- Distinguish covariate, label/prior, and concept drift
- Calculate a small illustrative PSI
- Use delayed labels and slices responsibly
- Follow an evidence-driven retraining decision
Distinguish operational health, drift and prediction quality
These terms name different responsibilities. Read the meaning before following them through the diagrams and worked example.
Core vocabulary
Four layers prevent one signal from telling the whole story
Service monitoring asks whether requests can be served: rate, error, latency, saturation, CPU/GPU/memory, and queue depth. Data monitoring asks whether inputs satisfy schema, missingness, ranges, categories, freshness, and expected distributions.
Operational freshness adds useful investigation signals: record the age of the serving model, the timestamp of the last successful approved training run, the last successful required data or feature refresh, and any stalled pipeline or run status. Model or pipeline age does not prove quality degradation and does not automatically justify retraining. A recent model may be bad and an older model may still perform correctly, so decisions still require actual data, outcome, quality, and release-evaluation evidence.
Connect prediction behaviour to delayed outcomes
Prediction monitoring observes score distributions, confidence, calibration estimates, abstentions, and predicted class balance. It can detect sudden behaviour before labels arrive, but it cannot prove correctness without outcomes.
Outcome monitoring joins later labels to the original prediction and calculates accuracy, precision, recall, calibration, false-positive/false-negative cost, and business KPIs. The join must use prediction time and recorded versions; using a later feature snapshot would confuse diagnosis.
Slice monitoring repeats important measures by region, customer segment, device, model version, and data-source version. A small slice needs uncertainty and sample-count context; noisy variation must not trigger unsupported conclusions.
Four monitoring layers answer four different questions
Is the service healthy, is the input changing, is the model behaving differently, and are outcomes still good?
Monitoring layers and responses
Distinguish a distribution change from a loss of accuracy
Drift types answer different questions
Worked Example: Calculate an illustrative three-bin PSI
Given: Expected proportions are [0.50, 0.30, 0.20]. Current proportions are [0.40, 0.35, 0.25]. For each bin use contribution = (current − expected) × ln(current / expected), then sum. All proportions are non-zero.
- Bin 1: (0.40 − 0.50) × ln(0.40/0.50) = −0.10 × ln(0.80) = −0.10 × −0.2231 ≈ 0.02231.
- Bin 2: (0.35 − 0.30) × ln(0.35/0.30) = 0.05 × ln(1.1667) = 0.05 × 0.1542 ≈ 0.00771.
- Bin 3: (0.25 − 0.20) × ln(0.25/0.20) = 0.05 × ln(1.25) = 0.05 × 0.2231 ≈ 0.01116.
- PSI ≈ 0.02231 + 0.00771 + 0.01116 = 0.04118, rounded to 0.0412.
- Interpret the value against a baseline, sample size, binning method, seasonality, and use-case-calibrated alert policy. Do not treat one copied threshold as universal.
Result and interpretation: The positive contributions summarize movement across these bins. PSI detects distribution difference; it does not identify the cause or prove that predictive performance declined.
PSI summarizes movement across distribution bins
Where does the illustrative PSI value come from?
The following figures turn the example into an operational decision. Follow every branch and note which state is recorded before work continues.
Drift starts an investigation—not an automatic retrain
Which evidence justifies creating and releasing a new model?
Calculate PSI and record the evidence behind an alert
The label above each block states what it is. Runnable Python can be executed as shown with the standard library; pseudocode and configuration communicate architecture and require adaptation to a real platform.
Calculate PSI transparently
The code exposes each contribution. Production implementations must define bin edges from an approved reference and handle zero proportions deliberately.
from math import log
expected = [0.50, 0.30, 0.20]
current = [0.40, 0.35, 0.25]
contributions = []
for e, c in zip(expected, current):
assert e > 0 and c > 0
contributions.append((c - e) * log(c / e))
print([round(x, 5) for x in contributions])
print(round(sum(contributions), 4))
# [0.02231, 0.00771, 0.01116]
# 0.0412Choose when to investigate, retrain or roll back
- Alert on sustained, material changes with sample-size context rather than every noisy fluctuation.
- Use outcome metrics when labels arrive; use data and prediction signals as earlier but weaker evidence.
- Calibrate thresholds by feature, population, seasonality, error cost, and response capability.
- Record model, feature, data-source, policy, and monitoring versions beside every prediction and outcome.
Failure Analysis and Recovery
Observed failure → likely cause → controlled response
Connect to Earlier Lessons
- Data visualization
Review distributions before constructing monitoring views.
- Bias–variance
Connect generalization error with changing production data.
- Agent observability
See trace-level monitoring for multi-step agents.
Summary / Key Takeaways
- Production monitoring combines service, data, prediction, and delayed outcome evidence.
- Covariate drift changes P(X), label drift changes P(y), and concept drift changes P(y|X); the terms are not interchangeable.
- Drift is evidence of distribution change, not automatic proof that model performance failed.
- Delayed labels must be joined to the original prediction time and recorded versions before outcome metrics are trustworthy.
- Slices can reveal regional, segment, device, model-version, or source-version failures hidden by aggregates.
- The illustrative three-bin PSI is about 0.0412, and its meaning depends on reference, bins, sample size, seasonality, and use case.
- Retraining is justified only after diagnosis, persistent degradation evidence, candidate evaluation, and controlled release gates.