What is data drift in machine learning?
Data drift is a change in the data a deployed model receives compared with the data it was trained on. A model learns patterns from one sample of the world, and when the inputs, the class mix, or the link between inputs and labels moves, its predictions can get worse without any error being raised. Model monitoring is the practice of measuring that change in production and acting on it.
Every production model needs monitoring. Fraud models face attackers who change tactics, demand forecasts meet new seasons and products, credit models see a different economy, and a broken upstream pipeline can feed a model values in the wrong units overnight. Teams track input statistics such as the KS test and the population stability index, watch the prediction distribution, and compare accuracy once labels arrive, then decide whether to retrain, recalibrate, or roll back.
Key ideas
- Data drift is any change between the training distribution and the data a model sees in production.
- Covariate shift changes P(x), label shift changes P(y), and concept drift changes P(y|x), the rule itself.
- Concept drift breaks a model even when the inputs look unchanged, so input monitoring alone cannot catch it.
- The KS test measures the largest gap between two empirical CDFs and flags even tiny shifts at large sample sizes.
- PSI sums (a − e)·ln(a/e) over bins and equals the symmetric KL divergence between the binned distributions.
- Testing many features on every check produces false alarms unless the threshold is corrected, for example with Bonferroni.
Short takes on this topic
Common questions
How often should a model be retrained?
There is no fixed schedule that suits every model. Some teams retrain on a calendar, such as weekly or monthly, and others retrain when monitoring shows drift or a drop in accuracy. Calendar retraining is simple but can miss sudden changes, while trigger-based retraining depends on the alerts being trustworthy. Many systems combine both.
Should I use the KS test, PSI, or another drift metric?
The KS test gives a p-value and needs no bins, so it suits continuous features, but with large samples it flags shifts too small to matter. PSI and other distances such as Wasserstein or Jensen-Shannon give an effect size, which is easier to threshold. Chi-square tests cover categorical features. Many teams report one test and one distance for each feature.
What is training-serving skew?
Training-serving skew is a difference between the features computed for training and the features computed at serving time for the same example. It usually comes from separate code paths, such as a batch job and an online service that round, join, or fill missing values differently. It looks like drift on day one of deployment, and the fix is in the pipeline rather than in retraining.
How do you detect drift in images, text, or embeddings?
Raw pixels and tokens are too high-dimensional for per-feature tests. A common approach is to reduce each input to a few numbers, such as the model's own softmax outputs or a low-dimensional projection of embeddings, and test those. Rabanser et al. found that tests on the outputs of a trained classifier detect many kinds of shift well. A domain classifier, trained to tell training inputs from live inputs, is another option: if it does better than chance, the distributions differ.
Related explainers
- Hypothesis Testing — Make principled decisions from data using null hypotheses, p-values, and significance levels
- KL Divergence — Measuring how different two distributions are
- Statistics Essentials — Mean, variance, standard deviation, and the Central Limit Theorem
- Model Evaluation & Metrics — Precision, recall, F1, ROC curves, and regression metrics
- Train, Validation & Test Sets — Splitting data to measure generalization and avoid overfitting
- Class Imbalance & Resampling — SMOTE, class weights, and metrics beyond accuracy
References
- Rabanser, Günnemann & Lipton (2019), "Failing Loudly: An Empirical Study of Methods for Detecting Dataset Shift"
- Gama et al. (2014), "A Survey on Concept Drift Adaptation", ACM Computing Surveys
- Lipton, Wang & Smola (2018), "Detecting and Correcting for Label Shift with Black Box Predictors"
Last updated