Interview's MateData Science
Interview's Mate

Data Science

Python → ML → MLOps

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Science topics
Lesson 155/ 160
08. MLOps & Model Deployment

Data Drift & Concept Drift Detection (Evidently AI)

Detect distribution shifts and concept drift before silent quality collapse.

AdvancedData Drift · Concept Drift3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Drift detection checks whether today's data looks different from the data your model learned from, so you can notice problems before the model's answers go wrong.

Think of it like…

A pilot watching instruments for changes in the weather. A shift in wind (data drift) is noted early and may not matter, a change that alters how the plane responds (concept drift) matters a lot, and the pilot needs both the instruments and a procedure for what to do when readings change.

Where you’ve seen it

A churn model monitors each feature weekly against its training reference. For a plan-type feature the reference proportions are (0.5, 0.3, 0.2) and the current week is (0.4, 0.3, 0.3). The PSI is the sum of (current − reference) × ln(current / reference): (−0.1) × ln(0.8) = 0.0223, 0 for the middle bin and (0.1) × ln(1.5) = 0.0405, so PSI = 0.063, below the common 0.1 "stable" threshold. A larger shift to (0.2, 0.3, 0.5) gives (−0.3) × ln(0.4) = 0.2749 plus (0.3) × ln(2.5) = 0.2749, PSI = 0.55, well above the 0.25 "major shift" level. Statistical tests need care: with a million rows per window, a Kolmogorov–Smirnov statistic only needs to exceed about 1.36 × √(2 / 1,000,000) ≈ 0.0019 to be significant at 5%, so trivially small shifts are "significant"; the team therefore uses effect-size thresholds (PSI or normalised Wasserstein distance) instead of p-values alone. Testing 50 features at α = 0.05 yields about 2.5 false alarms per run by chance, so alerts fire on a drift share (for example more than 30% of features drifted, or any of the top five important features drifting) rather than any single flag. An Evidently report with a data drift preset runs weekly over the last 7 days (at least 1,000 rows) against the reference and writes an HTML report and JSON metrics; default tests vary by version and sample size, so the team sets the statistical test and thresholds explicitly. One week it flags monthly_charges (PSI 0.31) and a null rate jump from 0.2% to 38%: the cause is an upstream ETL bug, not customer behaviour, fixed within a day. Another week shows genuine drift in tenure_months after a promotion brought in new customers; prediction drift rises and the delayed-label AUC check three weeks later shows a 0.02 drop, confirming impact and triggering retraining. Concept drift needs labels, so the team tracks cohort performance as labels mature and uses proxies such as score distribution and calibration meanwhile.

Words you’ll hear

Data drift
A change in the distribution of model inputs compared with training.
Concept drift
A change in how inputs relate to the target.
PSI
Population Stability Index, a binned distribution-shift score with rules of thumb at 0.1 and 0.25.
Drift share
The fraction of monitored features flagged as drifted.

Visual diagram

Loading interactive diagram

Theory & deep dive

Kinds of drift and how to measure them

Data (covariate) drift changes P(X) while P(y | X) may stay the same: a model can remain accurate if it extrapolates well, but errors rise where the new data lies outside the training region. Concept drift changes P(y | X): the model's learned relationship is no longer true, and performance falls regardless of how the inputs look. Label drift changes the base rate (churn rising from 15% to 20%), which shifts calibration and thresholds. Prediction drift (the distribution of scores) is observable immediately without labels and is a useful proxy. Compare a reference window (training data or a stable period) with a current window (for example the last 7 days) and require a minimum sample size (at least 1,000 rows) for stability.

PSI bins a feature and sums (current − reference) × ln(current / reference) over bins. For reference (0.5, 0.3, 0.2) and current (0.4, 0.3, 0.3): 0.1 × 0.2231 + 0 + 0.1 × 0.4055 = 0.063, which is below the common rules of thumb (under 0.1 stable, 0.1 to 0.25 moderate, above 0.25 major). For current (0.2, 0.3, 0.5): 0.2749 + 0 + 0.2749 = 0.55. KS compares empirical CDFs of numeric features, chi-square compares category counts, Jensen–Shannon and Wasserstein distances give bounded or interpretable magnitudes. Evidently provides these through drift presets whose default test depends on feature type and sample size, so specify the statistic and threshold you actually intend.

PSI by hand

Reference (0.5, 0.3, 0.2), current (0.4, 0.3, 0.3): PSI = (0.4−0.5)·ln(0.4/0.5) + 0 + (0.3−0.2)·ln(0.3/0.2) = 0.0223 + 0.0405 = 0.063. Current (0.2, 0.3, 0.5): 0.2749 + 0 + 0.2749 = 0.550. Thresholds: < 0.1 stable, 0.1–0.25 moderate, > 0.25 major.

Key takeaway: Know which distribution changed, measure it with an effect-size statistic and compare against a defined reference window.

Avoiding false alarms and responding to real drift

Significance versus importance: with a million rows per window, a KS statistic above about 1.36 × √(2 / 10⁶) ≈ 0.0019 is significant at the 5% level, so p-values flag trivial shifts; use effect-size thresholds (PSI, normalised Wasserstein distance) and look at feature importance. Multiple testing: monitoring 50 features at α = 0.05 yields about 2.5 false positives per run, so alert on a drift share (for example more than 30% of features) or on drift in the few most important features, and apply corrections or thresholds tuned on historical stable periods. Seasonality matters: compare with the same period last year or use multiple reference windows so weekends and holidays don't trigger alerts.

Triage in order: (1) data quality (null rate jumps, unit changes, new categories, schema changes: a null rate rising from 0.2% to 38% is a pipeline bug, not behaviour); (2) real population change (a promotion brings new customers); (3) performance impact. Measuring impact for concept drift requires labels, which often arrive late, so track delayed-label cohort performance (AUC and calibration per week as labels mature), prediction drift and business proxies in the meantime. Responses: fix the pipeline; retrain on recent data (with a gate); recalibrate or adjust thresholds for label drift; add features that capture the change; or pause automated decisions if the model is unreliable. Document a playbook, record each investigation and feed confirmed drift episodes into retraining triggers.

Multiple-testing arithmetic

50 features × α 0.05 = 2.5 expected false flags per run by chance alone. Alert rule: drift share > 30% (15+ of 50) or PSI > 0.25 on any of the top 5 features by importance. Large windows (n = 1M each): KS D > 0.0019 is 'significant', so use PSI as the effect size.

Key takeaway: Combine effect sizes, drift share and importance weighting, triage data quality first and confirm impact with delayed labels.

How it works, step by step

Step 1 of 4
Data scientist

1. Choose reference and current windows

Use the training or a stable period as reference, a recent window with enough rows as current and consider seasonality.

last 7 days · ≥ 1,000 rows
Key numbers at this step
Compare
same season

When to use it & trade-offs

What it is

A deployed model's world changes. Data drift (covariate shift) means the distribution of the inputs P(X) differs from training: customers get younger, a sensor is recalibrated, a new region launches. Concept drift means the relationship between inputs and the target P(y | X) has changed: the same customer profile now churns for different reasons after a competitor's offer. Label drift (prior shift) is a change in P(y), and prediction drift is a change in the distribution of the model's outputs. Drift is detected by comparing a reference window (usually the training or a known-good period) with a current window using statistical tests and distances: the Population Stability Index (PSI), the Kolmogorov–Smirnov test, chi-square for categories, Jensen–Shannon divergence and Wasserstein distance. Evidently AI is an open-source library that produces drift reports and test suites for these checks.

Why it matters: Models degrade silently. Accuracy can fall long before labels arrive to tell you, because many targets are delayed by weeks. Drift monitoring gives an early warning: it can reveal a broken upstream pipeline (a column suddenly 40% null), a unit change, a new population or a real behavioural shift. But drift alone is not damage: many drifts are harmless and a naive test on millions of rows flags trivial differences. Good practice combines effect-size measures, thresholds tuned to your data and a clear response playbook.

When to reach for it

  • Weekly drift reports on features, predictions and data quality
  • Early warning while labels are delayed
  • Triggers for investigation or retraining

When to avoid or be careful

  • Alerting on p-values alone with very large samples
  • Treating every drift flag as a model failure
  • Ignoring null-rate and unit changes that mimic drift

Drift measures

PSI
Best for: Binned numeric and categorical features with intuitive thresholds

Strengths: Single effect-size number; widely understood.

Watch out: Depends on binning; rules of thumb aren't universal.

Kolmogorov–Smirnov test
Best for: Numeric features on moderate sample sizes

Strengths: Non-parametric; p-value and statistic.

Watch out: Flags trivial shifts with huge samples.

Chi-square / Jensen–Shannon
Best for: Categorical distributions

Strengths: Handles category counts; JS is bounded.

Watch out: Sensitive to rare categories.

Wasserstein distance
Best for: Magnitude of numeric shifts

Strengths: Interpretable in feature units; scales with effect size.

Watch out: Needs normalisation across features.

Interview signals & numbers to know

When this topic comes up

  • “What is the difference between data drift and concept drift?”
  • How PSI is computed
  • Why p-values mislead with large samples
  • How to monitor without labels
  • What you do when drift is detected

Benchmarks & rules of thumb

0.1 · 0.25 -
common PSI thresholds for moderate and major shift
0.063 vs 0.55 -
PSI for the mild and strong shifts in the example
2.5 -
expected false flags among 50 features at α = 0.05

Common mistakes & follow-ups

Common interview mistakes

  • Comparing against a reference that includes anomalies.
  • Not checking for pipeline bugs before blaming customer behaviour.
  • Waiting for labels before looking at any signal.

Likely interviewer follow-ups

  • How would you detect concept drift when labels are delayed?
  • How do you choose drift thresholds?
  • When does drift justify retraining?
Interview tip: Compute a PSI on three bins by hand and mention multiple testing; both show you understand the statistics behind the dashboard.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Data Drift & Concept Drift Detection (Evidently AI) with data science interview Q&A and hands-on practice.

Open Data Science Q&A →Machine Learning Q&A
Previous topic
Model Registry & Stage Transitions
Next topic
Model Performance Monitoring & Alerting