Sub topic 3
Skew, Data Drift, and Concept Drift: How They Differ
This chapter assumes you know the supervised learning workflow (train, validate, predict), basic pandas, and simple statistics such as means and histograms. It also assumes you have seen the two data paths of a deployed model, the training path and the serving path.
Three problems are often confused because they all show up as "the model got worse in production." They have different causes, different evidence, and different fixes. Picking the wrong fix wastes time. Retraining a model that has a bug in its feature code, for example, just trains it on the same bug.
The three problems in one sentence each
- Training-serving skew is a difference between the features the model saw in training and the features it receives in serving, at the same point in time, caused by how the two pipelines are built.
- Data drift (also called covariate shift) is a change over time in the distribution of the input features in the real world, P(X). The pipelines are correct. The world moved.
- Concept drift is a change over time in the relationship between the inputs and the target, P(y | X). The inputs may look the same, but the right answer for them has changed.
The key question is where the difference comes from. Skew is a difference between two pipelines. Data drift is a difference between two periods. Concept drift is a difference between two rules that map inputs to labels.
A comparison
| Property | Training-serving skew | Data drift | Concept drift |
|---|---|---|---|
| What changes | Feature values produced by the serving path versus the training path | Distribution of real inputs, P(X) | Relationship P(y given X) |
| Root cause | Engineering: duplicated code, fit-time state, different sources, time leakage | The world or the user population | The world, user behavior, or business rules |
| Present from | Day one of deployment | Appears gradually or suddenly later | Appears gradually or suddenly later |
| Visible without labels | Yes, by comparing features | Yes, by comparing features over time | Usually no, needs labels or proxies |
| Typical fix | Fix the pipeline, share code, redeploy | Retrain on recent data, or reweight | Retrain with new labels, redesign features or target |
| Does retraining help | Not by itself | Often | Yes, if new labels exist |
Skew: a gap that exists on day one
Skew exists as soon as the model is deployed, because it comes from how the system was built. If the training code fills a missing age with the training mean (40) and the serving handler fills it with 0, then every request with a missing age is wrong from the first request. Nothing in the world has changed.
A useful test: take one raw record and run it through both paths. If the two feature vectors differ, you have skew. This test needs no time dimension at all.
import pandas as pd
raw = {"age": None}
# Training path: fill with the training mean
train_mean = 40.0
offline_age = pd.Series([raw["age"]]).fillna(train_mean).iloc[0]
# Serving path: a separately written handler
online_age = raw.get("age") or 0
print(offline_age, online_age) # 40.0 0
print("skew" if offline_age != online_age else "consistent")The two paths disagree on the same input, so this is skew.
Data drift: the inputs move, the pipelines agree
Suppose a lending model was trained on applicants whose median income was 52,000. A marketing campaign then brings in younger applicants with a median income of 38,000. Both pipelines compute income identically. The serving feature distribution simply differs from the training distribution because the population changed.
Data drift does not always hurt accuracy. If the model learned a good rule that holds across the new region of input space, performance can stay fine. It hurts when the model must extrapolate into regions it saw little of, or when the shift moves the mix of cases toward ones it handles poorly.
Data drift has the same symptom in the feature statistics as skew: the serving histogram does not match the training histogram. This is the main reason the two get confused. You cannot tell them apart by looking at a single distribution comparison.
Concept drift: the features look fine, the answers changed
Concept drift is about the label rule. Consider a fraud model. Fraudsters change tactics, so the same transaction pattern that used to mean "legitimate" now means "fraud." The feature distributions can be identical to training, so feature-level checks show nothing. Only labels reveal the problem: precision and recall fall once the true outcomes arrive.
Concept drift is common in cases where behavior is adversarial (fraud, spam), seasonal (demand forecasting), or tied to policy (pricing rules, regulations).
Telling them apart in practice
Two signals separate the cases: whether the gap is stable or changing over time, and whether the features or the labels moved.
flowchart TDThe diagram below encodes the triage as a decision tree.
Follow the order in the tree. Check for skew first, because it is the cheapest check and the one a mistake in code can cause. Only after the two pipelines are proven consistent does a distribution gap mean the world changed.
Why the distinction changes your action
Each problem points to a different response.
- Skew: Find the divergent code, state, or source. Fix it, add a parity test, and redeploy. Retraining on the same pipeline would reproduce the problem or even bake it in.
- Data drift: Confirm that the pipelines agree, then decide whether accuracy is affected. If it is, retrain on recent data, possibly with sample weights, and update the reference distribution you monitor against.
- Concept drift: Collect fresh labels and retrain. If the relationship keeps changing, shorten the retraining cycle, add features that capture the new behavior, or monitor delayed-label metrics closely.
Skew and drift can happen together
The categories are not exclusive. A system can have a serving-side bug and a shifting population at once. A common trap: after you fix skew, a residual gap in the distributions remains, and that remainder is real drift. Fix and verify one cause at a time, and compare against the training distribution again after each fix.
Another interaction: skew can look like drift. If a serving-side change (a new upstream data format, say) alters a feature on a given date, the monitoring chart shows a sudden step. A sudden step on a specific date often points to a pipeline or schema change rather than a change in user behavior. Gradual movement over weeks is more typical of drift in the world. This is a heuristic, not a rule, so confirm it with the replay test.
A simulated comparison
The next script builds a reference sample and three serving samples, one for each problem, and shows what a feature-level check sees. It uses the population stability index (PSI), which a later chapter covers in detail. For now treat it as a number that grows when two distributions differ.
import numpy as np
def psi(expected, actual, bins=10):
edges = np.unique(np.quantile(expected, np.linspace(0, 1, bins + 1)))
edges[0], edges[-1] = -np.inf, np.inf
e = np.histogram(expected, edges)[0] / len(expected)
a = np.histogram(actual, edges)[0] / len(actual)
e = np.clip(e, 1e-6, None)
a = np.clip(a, 1e-6, None)
return float(np.sum((a - e) * np.log(a / e)))
rng = np.random.default_rng(0)
n = 5000
# Training feature: income in thousands
train_income = rng.normal(52, 10, n)
# Skew: serving code divides by 1000 by mistake
skew_income = rng.normal(52, 10, n) / 1000
# Data drift: the population really earns less
drift_income = rng.normal(38, 10, n)
# Concept drift: income distribution is unchanged, only the label rule moves
concept_income = rng.normal(52, 10, n)
for name, values in [("skew", skew_income),
("data drift", drift_income),
("concept drift", concept_income)]:
print(f"{name:14s} PSI = {psi(train_income, values):.3f}")The skew case produces a very large PSI, the data drift case a moderate-to-large one, and the concept drift case a value near zero. The last result is the important lesson. A feature monitor cannot see concept drift, because the features did not change. Only labels can expose it. Likewise, the first two cases give a large PSI but do not say which cause is behind it. That is why the replay test comes first.
Common errors
- Calling every accuracy drop "drift." This skips the skew check and sends the team to retrain.
- Monitoring only features. Feature monitors catch skew and data drift but are blind to concept drift.
- Using the wrong reference. Compare serving features against the training data to detect skew. Comparing against last week's serving data detects change over time, which is drift. They answer different questions.
- Assuming labels arrive immediately. In many systems (loan defaults, churn) labels arrive weeks later. Concept drift is detected late, so feature and proxy metrics fill the gap in the meantime.
- Ignoring segments. An overall distribution may look stable while one segment, such as a single country, is badly skewed.
Exercise
A recommendation model's click-through rate dropped three days after launch. A replay of 1,000 raw events through the training and serving feature code produced identical feature vectors. The serving feature histograms match the training histograms closely, but the model's precision on newly labeled data is much lower than at validation time. Which of skew, data drift, or concept drift is most likely, and what is the next step?
Show answer
Concept drift is most likely. The identical replay rules out skew, and the matching histograms rule out data drift, so the inputs are unchanged but the relationship between inputs and outcomes has changed (or the validation setup did not reflect production behavior). The next step is to gather fresh labels, confirm the precision drop on a sufficient sample, and retrain with the new labels or revise the features and target.
Exercise
A feature monitor shows a sudden jump in the PSI of the "price" feature, starting exactly at 14:00 on one date, and then staying high. What is the first check you run, and why?
Show answer
Replay raw records from before and after 14:00 through both the training and serving feature code. A sudden step at a precise time suggests a pipeline, schema, or source change (such as a unit change from dollars to cents) rather than user behavior. If the two paths disagree, it is skew and the fix is in the pipeline. If they agree, treat it as data drift, such as a real price change, and decide whether to retrain.