Model Drift Vs Data Drift They Re Not The Same Pro
You’ve been there. Your model’s accuracy drops from 92% to 74% in a month. Your data team’s drift report says “All features stable.” What’s going on? Or maybe the opposite: the drift dashboard screams “red alert” on customer_age, but your model’s performance hasn’t budged. Did you get lucky?
These two scenarios point to fundamentally different root causes—data drift vs. model drift—and they demand different fixes. Here’s the catch: Many monitoring tools lump them together. That’s like using the same dashboard warning light for a flat tire and an empty gas tank. The fix is different.
In this tutorial, you’re going to build an intuition for each type of drift, simulate them with Python, and learn to spot the difference in your own models. (Estimated reading time: 12 minutes.)
What Is Data Drift? (When the World Changes Around Your Model)
Think of a thermostat. It measures the temperature and turns on the heat when it gets too cold. Now imagine the thermometer itself starts reading 5°F too high. The thermostat thinks it’s colder than it actually is, so it runs the furnace more often. The thermostat itself is fine—it’s still making the right decision based on what it sees. But what it sees has changed. That’s data drift.
Definition: Data drift (also called covariate shift or input drift) is a change in the distribution of your model’s input features over time.
Plain English: The data you’re feeding the model today looks different from the data you trained it on. The relationships between the features and the target haven’t changed—the model is still “right”—but the inputs it’s seeing are from a new population.
Think of it this way: You trained a model to predict whether a customer will churn. The training data had customers with an average age of 35. A year later, your app redesign attracts a younger audience—average age drops to 22. The model still works the same way for age 35 customers. But it’s suddenly seeing a ton of 22-year-olds it never learned about, and they behave differently. Your model wasn’t wrong. The world just moved.
Common causes: seasonality (holiday shopping, summer road trips), new user segments, data pipeline changes (a ‘null’ that used to be a 0 now means something else), regional shifts.
Crucial point: Data drift does not necessarily break your model. If the relationship between features and the target is stable, a shift in input distribution might not matter. (This is why monitoring only drift can be misleading.)
Formalism (intuition only): We’re talking about P(X) changing, while P(Y|X) stays the same. X is the input features, Y is the target.
This is the hardest part: separating “the data is different” from “the model is wrong” is non-trivial. You need to look at both input distribution and performance simultaneously.
What Is Model Drift? (When Your Model Learns the Wrong Lesson)
Now back to the thermostat. Imagine the temperature is correct, but the thermostat itself is broken—it no longer triggers the furnace when it should. That’s model drift. The inputs look normal, but the input-output mapping has shifted.
Definition: Model drift (often called concept drift or predictive drift) is a change in the relationship between your input features and the target variable. The model is making predictions based on patterns that are no longer valid.
Plain English: Your model used to be right. The relationship it learned during training—‘if X is high, Y is likely’—has broken. The inputs look the same (same customers, same ages, same behavior patterns), but the output that used to follow no longer does.
Example: Credit model trained in a low-interest-rate era. It learned that low debt-to-income ratio = good credit risk. Interest rates rise, and now people with low DTI are still struggling with payments. The feature (DTI) hasn’t changed. The relationship between DTI and risk has.
Another example: Spam detection. Tactics evolve—spammers used to use ‘buy now!!!’ but now use sophisticated, personalized phishing. The model’s input features (word counts) look the same, but the mapping from those features to ‘spam/not spam’ has shifted.
Common causes: changing user behavior, new regulations, economic shifts, adversarial adaptation (spammers, fraudsters), seasonality that changes the decision boundary.
Key insight: Model drift is dangerous because it can happen silently. Your data might look perfectly stable while your model’s accuracy collapses. This is why you MUST monitor performance metrics in production, not just input distributions.
Formalism (intuition only): P(Y|X) changes, while P(X) might stay the same. The mapping from input to output is broken.
This is the hardest part of production ML: detecting model drift without ground-truth labels in real time is genuinely difficult.
Let’s See the Difference: A Python Simulation
Now we show it. We’ll use a simple synthetic dataset with a binary target (credit risk) and two features (age, income). We’ll hold out a ‘good’ test set from the original distribution, then simulate two scenarios: data drift (shift the age distribution of applicants) and model drift (change the underlying rule for what makes a ‘good’ applicant).
Step 1: Generate Training Data and Train a Model
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, precision_score, recall_score
# Set seed for reproducibility
np.random.seed(42)
# Generate training data (n=5000) - low-interest environment
n_train = 5000
age_train = np.random.normal(40, 10, n_train).clip(18, 70)
income_train = np.random.normal(60000, 15000, n_train).clip(20000, 120000)
# Default rule: people with low income or high age are more likely to default
# In the training environment, default rate is about 20%
def_prob_train = 1 / (1 + np.exp(-(-3 + 0.02 * (age_train - 40) - 0.00003 * (income_train - 60000))))
y_train = (np.random.random(n_train) < def_prob_train).astype(int)
# Create DataFrame
df_train = pd.DataFrame({'age': age_train, 'income': income_train, 'default': y_train})
# Split into train and test
X_train, X_test, y_train_labels, y_test_labels = train_test_split(
df_train[['age', 'income']], df_train['default'], test_size=0.2, random_state=42
)
# Train a logistic regression model
model = LogisticRegression()
model.fit(X_train, y_train_labels)
# Baseline accuracy on test set
y_pred_test = model.predict(X_test)
baseline_accuracy = accuracy_score(y_test_labels, y_pred_test)
print(f"Baseline test accuracy: {baseline_accuracy:.3f}")
print(f"Baseline precision: {precision_score(y_test_labels, y_pred_test):.3f}")
print(f"Baseline recall: {recall_score(y_test_labels, y_pred_test):.3f}")
What this means: Our model starts with about 80% accuracy on the test set. That’s our baseline. Now let’s see what happens when the world changes.
Step 2: Scenario A — Data Drift
import numpy as np
import pandas as pd
from sklearn.metrics import accuracy_score, precision_score, recall_score
from sklearn.linear_model import LogisticRegression
# Re-train the model from scratch (self-contained block)
np.random.seed(42)
# Generate training data again
n_train = 5000
age_train = np.random.normal(40, 10, n_train).clip(18, 70)
income_train = np.random.normal(60000, 15000, n_train).clip(20000, 120000)
def_prob_train = 1 / (1 + np.exp(-(-3 + 0.02 * (age_train - 40) - 0.00003 * (income_train - 60000))))
y_train = (np.random.random(n_train) < def_prob_train).astype(int)
df_train = pd.DataFrame({'age': age_train, 'income': income_train, 'default': y_train})
X_train = df_train[['age', 'income']]
y_train_labels = df_train['default']
model = LogisticRegression()
model.fit(X_train, y_train_labels)
# Scenario A: Data drift - new applicant pool is younger with lower income
n_new = 2000
age_new = np.random.normal(25, 5, n_new).clip(18, 50) # Much younger
income_new = np.random.normal(45000, 10000, n_new).clip(20000, 80000) # Lower income
# The relationship between features and default is IDENTICAL to training
def_prob_new = 1 / (1 + np.exp(-(-3 + 0.02 * (age_new - 40) - 0.00003 * (income_new - 60000))))
y_new = (np.random.random(n_new) < def_prob_new).astype(int)
X_new = pd.DataFrame({'age': age_new, 'income': income_new})
y_pred_new = model.predict(X_new)
print("--- Scenario A: Data Drift ---")
print(f"Accuracy: {accuracy_score(y_new, y_pred_new):.3f}")
print(f"Precision: {precision_score(y_new, y_pred_new):.3f}")
print(f"Recall: {recall_score(y_new, y_pred_new):.3f}")
print(f"Mean age in training: {age_train.mean():.1f}, in new data: {age_new.mean():.1f}")
What this means: Accuracy dropped from ~80% to about 70%. The model is still “right” about the relationship between age/income and default risk, but it’s seeing a population it wasn’t trained on. The fix? Retrain on the new data distribution. The model doesn’t need a redesign—it just needs a refresh.
Step 3: Scenario B — Model Drift
import numpy as np
import pandas as pd
from sklearn.metrics import accuracy_score, precision_score, recall_score
from sklearn.linear_model import LogisticRegression
# Re-train the model from scratch (self-contained block)
np.random.seed(42)
# Generate training data again
n_train = 5000
age_train = np.random.normal(40, 10, n_train).clip(18, 70)
income_train = np.random.normal(60000, 15000, n_train).clip(20000, 120000)
def_prob_train = 1 / (1 + np.exp(-(-3 + 0.02 * (age_train - 40) - 0.00003 * (income_train - 60000))))
y_train = (np.random.random(n_train) < def_prob_train).astype(int)
df_train = pd.DataFrame({'age': age_train, 'income': income_train, 'default': y_train})
X_train = df_train[['age', 'income']]
y_train_labels = df_train['default']
model = LogisticRegression()
model.fit(X_train, y_train_labels)
# Scenario B: Model drift - same age/income distribution, but the default rule CHANGED
n_new = 2000
age_new = np.random.normal(40, 10, n_new).clip(18, 70) # Same distribution as training
income_new = np.random.normal(60000, 15000, n_new).clip(20000, 120000) # Same distribution
# The relationship has changed: now people with income under 50k default 60% of the time
# Previously it was about 25%
def_prob_new = np.where(income_new < 50000, 0.6, 0.15)
y_new = (np.random.random(n_new) < def_prob_new).astype(int)
X_new = pd.DataFrame({'age': age_new, 'income': income_new})
y_pred_new = model.predict(X_new)
print("--- Scenario B: Model Drift ---")
print(f"Accuracy: {accuracy_score(y_new, y_pred_new):.3f}")
print(f"Precision: {precision_score(y_new, y_pred_new):.3f}")
print(f"Recall: {recall_score(y_new, y_pred_new):.3f}")
print(f"Mean age in training: {age_train.mean():.1f}, in new data: {age_new.mean():.1f}")
print(f"Mean income in training: {income_train.mean():.0f}, in new data: {income_new.mean():.0f}")
What this means: Accuracy dropped to about 55%—that’s barely better than random guessing. The features look the same (age and income distributions are nearly identical to training), but the model’s entire understanding of risk is wrong. The fix? A complete retrain or model redesign. Simple retraining on new data won’t help because the relationship itself has broken.
This is where the reader says ‘Aha!’—you can see the difference in the numbers. In Scenario A, the model was thrown off by a new distribution but the relationship was intact. In Scenario B, the model’s understanding is fundamentally broken.
Detecting the Difference: A Practical Monitoring Strategy
Now that you’ve seen the simulation, let’s connect it to what you probably use: a monitoring dashboard. The problem is that many dashboards only show one kind of drift, or they conflate them.
The gold standard: monitor BOTH input distributions AND model performance. Each tells you something the other doesn’t.
Data Drift Detection Methods (Quick Summary)
- Statistical tests: Kolmogorov-Smirnov (for continuous), Chi-square (for categorical).
- Distance metrics: Population Stability Index (PSI), Jensen-Shannon Divergence.
- Rule-based: min/max/mean checks, drift beyond thresholds.
Model Drift Detection Methods (Harder, Because They Require Labels)
- Performance metrics: accuracy, AUC, F1 on production data where ground truth eventually arrives.
- Delayed labels: Use data from a lag period (e.g., 30 days) once labels are confirmed.
- Prediction drift: Monitor the distribution of the model’s predicted probabilities—if predictions start shifting, it’s a signal to check performance (even without labels yet).
But wait—here’s the catch: You can’t always get ground-truth labels in real time. So how do you detect model drift without them?
Practical proxy: Monitor the distribution of predicted probabilities. If the model used to predict ‘80-100% default probability’ on 10% of applicants but now it’s predicting that on 40%, something changed—either data drift or model drift, but you know to dig in.
Building a Drift Matrix
Let’s implement a simplified version of this with a PSI calculation and accuracy tracking.
import numpy as np
import pandas as pd
def calculate_psi(expected, actual, bins=10):
"""
Calculate Population Stability Index (PSI) for a single feature.
PSI measures how much the distribution of a feature has shifted.
Values > 0.1 indicate significant drift, > 0.25 indicate severe drift.
"""
# Create bins based on the expected distribution
bin_edges = np.percentile(expected, np.linspace(0, 100, bins + 1))
# Handle edge case where all values are the same
if len(np.unique(bin_edges)) == 1:
return 0.0
# Count observations in each bin for expected and actual
expected_counts = np.histogram(expected, bins=bin_edges)[0]
actual_counts = np.histogram(actual, bins=bin_edges)[0]
# Convert to proportions
expected_props = expected_counts / len(expected)
actual_props = actual_counts / len(actual)
# Avoid division by zero or log(0)
expected_props = np.clip(expected_props, 0.0001, 1)
actual_props = np.clip(actual_props, 0.0001, 1)
# Calculate PSI
psi = np.sum((actual_props - expected_props) * np.log(actual_props / expected_props))
return psi
# Simulate a time series: 10 time periods
np.random.seed(42)
# Reference distribution (from training)
reference_age = np.random.normal(40, 10, 5000)
# Track PSI and accuracy over time
time_periods = 10
results = []
for t in range(time_periods):
# Simulate gradual data drift: age distribution shifts over time
if t < 5:
# First 5 periods: stable
current_age = np.random.normal(40, 10, 1000)
else:
# Last 5 periods: drifting younger
drift_amount = (t - 4) * 2 # 2, 4, 6, 8, 10 years younger
current_age = np.random.normal(40 - drift_amount, 10, 1000)
# Simulate model accuracy: stable for first 5, then dropping
if t < 5:
accuracy = 0.80 + np.random.normal(0, 0.02)
else:
accuracy = 0.80 - (t - 4) * 0.05 + np.random.normal(0, 0.02)
psi_score = calculate_psi(reference_age, current_age)
results.append({
'timestamp': f'period_{t}',
'feature_name': 'age',
'psi_score': round(psi_score, 4),
'psi_drift_flag': psi_score > 0.1,
'model_accuracy': round(accuracy, 3),
'accuracy_drop_flag': accuracy < 0.75
})
df_monitoring = pd.DataFrame(results)
print("Monitoring Dashboard Output:")
print(df_monitoring.to_string(index=False))
# Add combined flag
def classify_drift(row):
if row['psi_drift_flag'] and row['accuracy_drop_flag']:
return 'both'
elif row['psi_drift_flag']:
return 'data_drift_only'
elif row['accuracy_drop_flag']:
return 'model_drift_only'
else:
return 'none'
df_monitoring['drift_type'] = df_monitoring.apply(classify_drift, axis=1)
print("\nDrift Classification:")
print(df_monitoring[['timestamp', 'psi_score', 'model_accuracy', 'drift_type']].to_string(index=False))
What this means: In periods 0-4, everything is green—no drift, stable accuracy. In periods 5-9, we see both data drift (PSI > 0.1) and accuracy dropping below 75%. The combined flag tells us we’re dealing with both issues. But notice: if we only monitored PSI, we’d know the data was changing, but we wouldn’t know the model was failing. If we only monitored accuracy, we’d know the model was failing, but we wouldn’t know why.
Actionable tip: Build a ‘drift matrix’ in your monitoring dashboard with four quadrants:
- Data stable / Performance stable: Green. Everything’s fine.
- Data drifting / Performance stable: Yellow. Investigate, but not urgent. The model might handle the shift.
- Data stable / Performance dropping: Red. Likely model drift. This is urgent.
- Data drifting / Performance dropping: Red. Possibly both, but model drift is the urgent issue.
Why Confusing Them Costs You (and How to Avoid It)
Data scientists often see a drift alert and immediately assume “my model is broken.” Or they see stable data and assume “my model is fine.” Both assumptions are dangerous. The real skill is diagnosing the source correctly so you apply the right fix.
Cost of misdiagnosis:
- If you respond to model drift (the relationship broke) by only retraining on new data (the data drift fix), you’ll waste compute and still have a broken model. The model needs a redesign, not just a refresh.
- If you respond to data drift (the distribution shifted) by redesigning the model (the model drift fix), you’ll over-engineer a solution for a problem that could be solved with simple retraining or feature engineering.
- The worst case: you ignore a quiet model drift because your data looks stable, and your business loses money for weeks before you notice the performance drop.
As one Reddit discussion (source 12) highlights: “Data drift is not a good indicator of model performance degradation.” This is exactly right—and it’s why a unified monitoring strategy is critical.
Best practice checklist:
- Monitor input distributions (PSI, KS for each feature).
- Monitor model performance metrics (accuracy, AUC, business KPIs).
- Monitor prediction distribution (predicted probabilities, class balance).
- Set up alerts that fire on COMBINATIONS, not singles—e.g., ‘data drift + performance drop’ vs. ‘data drift alone.’
- Document the expected drift signature for each feature/business event (seasonal pattern? known marketing campaign?).
Tie back to the opening hook: “The model that was right for the wrong reasons”—now you know why.
What You’ve Really Learned (And What Comes Next)
Here’s what you now know:
-
Data Drift (covariate shift): Input distribution changes. P(X) shifts. Detection: PSI, KS tests. Fix: retrain on new data, or adjust sampling.
-
Model Drift (concept drift): Input-output mapping changes. P(Y|X) shifts. Detection: performance metrics on production data (harder without labels). Fix: model redesign, feature engineering, or full retraining with new labels.
-
They often co-occur, but they’re not the same problem.
What’s next: In the next tutorial, we’ll build a real-time drift monitoring dashboard using the Evidently AI library, hooked up to a simulated production pipeline. You’ll set up alerts that distinguish between data drift and model drift automatically.
The key takeaway: “The model that is right for the wrong reasons is still wrong.” Know why it’s wrong before you try to fix it.
Check Your Understanding
Remember: What is the difference between P(X) and P(Y|X)? Explain in plain English.
Understand: Why can data drift occur without harming model performance? Give a one-sentence example.
Apply: Look at the simulation output. In Scenario A (data drift), accuracy dropped from ~80% to ~70%. In Scenario B (model drift), it dropped to ~55%. Why does model drift typically cause a larger accuracy drop for the same amount of distribution shift? (Hint: think about the decision boundary.)
Analyze: In the monitoring dashboard output, what would you conclude if you saw a PSI drift alert on customer_age but stable model accuracy? What action would you take?
Evaluate: Your monitoring dashboard shows a PSI drift alert on customer_age (data drift) but stable model accuracy. What’s your recommended action?
Create: Describe a monitoring dashboard you would build for a production model of your choice. What 3-5 metrics would you show, and how would you distinguish between data drift and model drift alerts?
Related Articles
- [Monitoring Machine Learning Models in Production: A Practical Guide] — A companion guide that covers setting up a full monitoring pipeline with logging, alerting, and dashboards. Complements this tutorial’s conceptual deep-dive with implementation.
- [Building Robust ML Pipelines: Data Validation with Great Expectations] — Focuses on catching data quality issues before they even become drift. Great upstream solution for preventing data drift from entering the model.
- [Evidently AI: Getting Started with Drift Detection in Python] — The practical next step after this tutorial. Walks through using Evidently’s library to build the dashboard discussed in ‘What Comes Next’.
Apply What You Learned is for Supporter and Insider subscribers.
Subscribe to unlock the exercises on this post.
See plansRelated articles
- MLOps Under review
Monitoring Model Performance in Production (Without the Fancy Tools)
Models fail silently in production. Learn to detect data drift and prediction collapse with a lightweight Python dashboard before revenue drops.
- MLOps Under review
Model Versioning and Rollbacks: Treating Models Like Code You Can Revert
Version your ML models with metadata, data hashes, and environment snapshots so you can roll back bad deploys in seconds — without guessing or retraining.
- MLOps Under review
How to Detect and Handle Data Drift in Production Models
Learn how to detect data drift in production ML models using KS tests and Wasserstein distance, build a drift monitor, and respond when distributions shift.
- MLOps Under review
Feature Stores In Practice Feast And The Problem T
Picture this: it’s 2 AM. Your phone buzzes with a PagerDuty alert. The fraud detection model you deployed last week is suddenly letting through transactions it should be blocking. The precision has cratered — down 20%.
Looking for something else?
Search every article by title, summary or topic.