Sub topic 12
When drift matters and when it does not
This chapter assumes you can run the KS test and compute PSI on a feature, as covered earlier. It covers how to decide whether a drift signal calls for action.
Drift is a symptom, not a failure
A drift test tells you that a feature's distribution changed between the reference window and the current window. It does not tell you that the model got worse. With 5,000 or more rows, the KS test flags shifts far too small to affect predictions. A tiny p-value only means the shift is detectable.
Drift hurts performance only when the change moves data into regions where the model is wrong, or changes the relationship between inputs and the label. Three situations show the difference.
- Harmless drift. A feature with low importance shifts, or the shift stays inside the range the model learned from. Predictions barely move.
- Harmful covariate shift. An important feature moves into a sparse or unseen region, such as a new customer segment. The model extrapolates and its error rises.
- Harmful concept drift. The input distributions look stable, but the label rule changed. Drift tests on features will not catch this. Only performance monitoring will.
Weighting drift by importance
A practical first filter is to combine each feature's drift score with its importance to the model. The example below uses a made-up importance table. In practice, take the values from permutation importance or SHAP on your validation set.
import numpy as np
from scipy.stats import ks_2samp
rng = np.random.default_rng(0)
importance = {"income": 0.70, "age": 0.25, "zip_noise": 0.05}
reference = {name: rng.normal(0, 1, 5000) for name in importance}
current = {name: rng.normal(0, 1, 5000) for name in importance}
current["zip_noise"] = current["zip_noise"] + 0.4 # shift a low-importance feature
for name, weight in importance.items():
stat = ks_2samp(reference[name], current[name]).statistic
print(f"{name:10s} KS={stat:.3f} importance={weight:.2f} weighted={stat * weight:.3f}")zip_noise has the largest KS statistic but the smallest weighted score. Rank alerts by the weighted score so that shifts in important features come first.
A triage flow
Use drift as a trigger for investigation, then let outcome evidence decide the action.
The data quality check comes first. A sensor reporting -999 or a column that arrives as all nulls produces dramatic drift. Retraining on that data would make things worse.
Common errors
- Alerting on every p-value below 0.05. Across hundreds of features and daily windows, some tests will fire by chance. Use an effect-size measure such as the KS statistic or PSI, and require persistence over several windows.
- Assuming no drift means no problem. Concept drift and label shift can occur without visible feature drift. Keep performance or proxy metrics.
- Retraining automatically on drift. If the cause is a pipeline bug, you encode the bug into the model.
- Ignoring prediction drift. If the score distribution moves while important features look stable, interactions are shifting. Check the multivariate drift test.
Exercise
A KS test on a low-importance feature gives p = 1e-30 (statistic 0.12). Accuracy computed on labels from the same window is unchanged and the data quality checks pass. What should you do?
Show answer
Log the alert and take no action, though you may lower its priority or raise its threshold. The shift is statistically detectable but has no measured effect on performance, and the feature has little influence on predictions. Keep watching it in later windows in case the shift grows or other signals appear.