Lesson 2 of 4 Monitoring Models in Production

Detecting and Responding to Data Drift

This lesson explains how to detect changes in production data distributions, understand their type and choose the right response, since accuracy usually falls when data no longer resembles training data.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish data drift, label drift and concept drift.
  • Quantify drift with statistical measures.
  • Respond to drift, starting with pipeline error checks.

Types of drift

Data drift (covariate shift) is a change in the distribution of inputs, such as customers becoming younger or a new product category appearing. Label (prior) drift is a change in the distribution of the target, such as fraud rates doubling. Concept drift is a change in the relationship between inputs and the target: the same inputs now lead to different outcomes, as when customers' price sensitivity changes in a recession. Data drift can be detected from inputs alone; concept drift needs labels.

The following diagram contrasts the three kinds of drift.

Three kinds of drift. In data drift, the distribution of inputs moves, for example customers become younger, and it can be seen from inputs alone. In label drift, the share of each outcome changes, for example fraud doubles. In concept drift, the same inputs now lead to different outcomes, which only labels reveal.
The distributions and rates are illustrative.

Statistical measures

Drift is quantified by comparing current and baseline distributions. The Kolmogorov-Smirnov (KS) statistic measures the largest gap between cumulative distributions of a numeric feature. The population stability index (PSI) compares binned distributions; values above about 0.2 usually indicate significant shift. Jensen-Shannon divergence and L-infinity distance compare categorical distributions; Model Monitor uses distance measures such as these in its drift checks. Monitoring prediction distributions is also useful: a sudden change in the share of positive predictions is often the first visible sign.

The following diagram shows the jump and its likely cause.

Overnight drift in one feature. The mean transaction amount jumps about a hundredfold while every other feature stays flat, which points to a unit change upstream, such as amounts sent in cents instead of dollars, rather than a change in behaviour. The fix is the upstream conversion; retraining on the faulty data would teach the model nonsense.
The values are illustrative; bar heights use a log scale.
Match the pairs

Drift statistics

Exam skills 4.1.3

Match each statistic with how it is used to detect drift.

Log in to try this activity Interactive activities are free with an account.

Responding to drift

Not every drift alert should trigger retraining. The first step is to check for data pipeline errors, such as a change of units, a broken join or a new default value, which produce sudden drift and should be fixed at the source rather than learned by the model.

Some drift is expected, such as seasonal changes in shopping behaviour, and may already be reflected in the training data. Genuine and lasting change in the real world calls for retraining on recent data, possibly with new features that capture the change. The following table summarises the types of drift.

DriftWhat changesDetect withTypical response
Data driftInput distributionsData quality monitor, KS, PSIInvestigate source; retrain if real
Label driftTarget distributionLabel statisticsRecalibrate or retrain
Concept driftInput-target relationshipModel quality monitor (needs labels)Retrain, revisit features
Pipeline errorValues due to a bugSudden drift in a few featuresFix the pipeline, not the model
Troubleshooting scenario

Drift alerts

Exam skills 4.1.3 · 3.3.5

Respond to drift alerts one at a time.

Log in to try this activity Interactive activities are free with an account.
Worked example

Sudden drift in one feature

Overnight, Model Monitor reports severe drift in transaction_amount for a fraud model: the mean rose about 100 times. No other feature changed.

A hundredfold jump in one feature overnight suggests a unit change, such as amounts sent in cents instead of dollars after an upstream release, rather than real behaviour change. Fixing the upstream conversion is the right response. Retraining on the faulty data would teach the model nonsense.

Check yourself

What is the difference between data drift and concept drift?

Show answer

Data drift is a change in the inputs. Concept drift is a change in the relationship between inputs and outputs, which needs ground-truth labels to detect.

Exam Tips

Remember for the exam

  • Inputs change: data drift; input-output relationship changes: concept drift.
  • Concept drift detection needs ground-truth labels.
  • KS and PSI quantify numeric distribution shift.
  • Sudden, extreme drift in one feature often means a pipeline bug.
  • Retrain only for genuine, lasting change.