Skip to main content
LearnMLAcademy
Advanced10 min read

ML Monitoring, Data Drift & Model Decay

Detect data drift, concept drift, and performance decay using Evidently metrics, with pipeline maps, deployment choices, and production reliability checks.

What you will master in this lesson
Intuitive core mechanisms & practical real-world intuition
Step-by-step mathematical breakdown & visual diagrams
Runnable Python implementation & practical trade-offs

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

Core vocabulary
TermMeaning in this lesson
Covariate/data driftThe distribution of input X changes, such as monthly_spend shifting.
Label/prior driftThe frequency of outcome y changes, such as the churn rate rising.
Concept driftThe relationship P(y|X) changes, so the same inputs imply a different outcome risk.
CalibrationWhether predicted probabilities match observed frequencies; among predictions near 0.7, roughly 70% should be positive when calibrated.
Delayed labelA ground-truth outcome observed after the prediction, such as churn 30 days later.
SliceA meaningful subgroup such as region, device, customer segment, or model version.
PSIPopulation Stability Index, a binned distribution-change summary used here only as an illustrative diagnostic.

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?

1 · Servicerate, errors, latency, saturation, CPU/GPU, queue
2 · Dataschema, missingness, freshness, distributions
3 · Predictionsscores, confidence, calibration, abstentions
4 · Outcomesdelayed labels, errors, cost, business KPI
Join by request, model, feature, and data-source versions to diagnose causes
How to read it: No single dashboard proves model health. Service, data, prediction, and delayed outcome signals must be connected by model and data versions.

Monitoring layers and responses

Monitoring layers and responses
LayerSignalsFirst question
Servicerate, errors, latency, saturation, resources, queueCan the system serve correctly and on time?
Dataschema, missingness, ranges, categories, freshness, driftDid the input or pipeline change?
Predictionscore/class distribution, confidence, calibration proxy, abstentionIs model behaviour changing before labels arrive?
Outcomequality metrics, error cost, business KPIDid usefulness actually degrade when truth became known?

Distinguish a distribution change from a loss of accuracy

Drift types answer different questions

Drift types answer different questions
TypeWhat changedExampleWhat it does not prove
Covariate/dataP(X)More customers have high monthly_spendThat predictions are now wrong
Label/priorP(y)Churn prevalence rises from 8% to 13%Why prevalence changed
ConceptP(y|X)The same usage pattern now implies greater churn riskThat input distributions must also move

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.

  1. Bin 1: (0.40 − 0.50) × ln(0.40/0.50) = −0.10 × ln(0.80) = −0.10 × −0.2231 ≈ 0.02231.
  2. Bin 2: (0.35 − 0.30) × ln(0.35/0.30) = 0.05 × ln(1.1667) = 0.05 × 0.1542 ≈ 0.00771.
  3. Bin 3: (0.25 − 0.20) × ln(0.25/0.20) = 0.05 × ln(1.25) = 0.05 × 0.2231 ≈ 0.01116.
  4. PSI ≈ 0.02231 + 0.00771 + 0.01116 = 0.04118, rounded to 0.0412.
  5. 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?

Bin 1
.50 → .40
Bin 2
.30 → .35
Bin 3
.20 → .25
■ Expected■ CurrentPSI ≈ 0.0412
How to read it: Each bar compares the expected and current proportion for one bin. The contribution (current − expected) × ln(current / expected) is calculated per bin and then summed.

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?

Drift alert
Pipeline/data defect?repair and remeasure
Outcome degradation?wait for labels; inspect slices
Persistent and material?use-case evidence
Train + evaluate candidatequality and operations
Release only if bettercanary + rollback
How to read it: First exclude broken pipelines and temporary events. Confirm persistent outcome degradation, then evaluate a candidate. Release only when the candidate clears the same quality and operational gates.

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.

Calculate PSI transparentlyPythonRUNNABLE PYTHON
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.0412

Choose 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

Observed failure → likely cause → controlled response
Observed failureLikely causeResponse
Latency healthy, model harms usersOnly infrastructure is monitoredAdd predictions, outcomes, slices, and business cost
Drift alert causes needless retrainChange treated as proof of decayInvestigate pipeline, persistence, and labelled performance
Overall metric stable, one group degradesAggregate hides slicesMonitor meaningful segments with sample counts
Outcome join is wrongDelayed label linked to latest instead of original predictionJoin by entity and prediction/cutoff time with version lineage

Connect to Earlier Lessons

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.

Apply this concept in a real hands-on project

You have studied the idea. Now use it in working Python code, see the calculation and output, and explain what changed. Each project includes step-by-step instructions, full source and tests.

Practice challenge: predict an outcome first, run the code, and explain the difference.

Track Your Progress0% curriculum done

Finished "ML Monitoring, Data Drift & Model Decay"?

Mark this lesson as completed to update your progress bar and track your milestones across the full curriculum.

Overall Progress0 / 167 lessons

Was this tutorial helpful?

Your feedback helps us continuously refine and improve our open-access tutorials.

Knowledge Check

Progress: 0/5

Test your active recall. Choose one answer for each question, then check it to reveal the step-by-step reasoning.

Question 1 of 5interpretation
Monthly_spend changes distribution but labelled recall remains stable. Which conclusion is justified?
Question 2 of 5numerical/formula
Using the lesson's three bins, what is the approximate PSI?
Question 3 of 5conceptual
The share of positive labels rises while the input distributions appear stable. Which drift type is directly observed?
Question 4 of 5application/scenario
Why record prediction time when labels arrive 30 days later?
Question 5 of 5debugging/diagnostic
Overall accuracy is stable, but one device slice deteriorates. What is the best next action?

Knowledge Check Review & Explanations

Review the questions, verified correct answers, and conceptual explanations for this lesson.

1Monthly_spend changes distribution but labelled recall remains stable. Which conclusion is justified?▼

Correct Answer: Covariate drift occurred, but failure is not proven

The input distribution changed, which is covariate drift. Stable labelled recall means this signal alone does not prove model decay.

2Using the lesson's three bins, what is the approximate PSI?▼

Correct Answer: 0.0412

The contributions 0.02231, 0.00771, and 0.01116 sum to approximately 0.04118, rounded to 0.0412.

3The share of positive labels rises while the input distributions appear stable. Which drift type is directly observed?▼

Correct Answer: Label/prior drift

Label/prior drift concerns P(y), the outcome frequency. Input movement would concern P(X), while concept drift concerns P(y|X).

4Why record prediction time when labels arrive 30 days later?▼

Correct Answer: To join truth to the exact earlier prediction and its versions

Outcome evaluation must reconstruct what was predicted when and with which model, features, and policy. A latest-state join can misattribute results.

5Overall accuracy is stable, but one device slice deteriorates. What is the best next action?▼

Correct Answer: Check sample size, source/version changes, and labelled slice performance

Slice evidence needs volume and lineage context. Diagnose the device pipeline and outcomes before choosing repair or retraining.

Keep moving through the path

Continue Learning

Free Download: ML Interview Cheatsheet

100 essential Machine Learning interview questions and answers covering foundations, algorithms, evaluation, deep learning, Python, system design and interview strategy. Enter your email to download it instantly.

Next