Data drift detection in machine learning is the practice of identifying when the statistical properties of production data have shifted away from the distribution the model was trained on. It sounds straightforward. In practice it is one of the most consequential and most skipped parts of operating an ML system at scale. If you are choosing between KS, PSI, and Wasserstein for a given feature type, the Drift Test Selector recommends a test from your data shape and detection goal.
A pipeline can continue serving plausible predictions after its input mix changes. Input-distribution monitoring provides evidence for investigation while outcomes are still unavailable. Pair it with monitoring models without ground truth so a changed distribution is not mistaken for measured performance loss.
What Exactly Is Data Drift
The term is used loosely, so it helps to be precise. Data drift specifically refers to a change in the distribution of input features: the joint or marginal distribution P(X) has shifted between training time and inference time. The model learned a mapping from some P_train(X) to an output space; if P_prod(X) diverges significantly, predictions land outside the model’s reliable operating range.
This is distinct from concept drift, where the relationship between inputs and the target changes, meaning P(Y|X) shifts rather than P(X). Both matter, but they require different monitoring strategies. Data drift can be detected without access to labels; concept drift detection usually requires ground truth feedback with some lag. The full comparison, including prediction drift, is in concept drift vs data drift explained.
A third category, label drift (shifts in P(Y)), is relevant in classification tasks but is often conflated with concept drift. In practice, most teams start with input feature monitoring and add label-based signals once they have a reliable feedback loop. For the full set, including the schema, unit, and missingness drifts that come out of your own pipeline rather than the world, see types of data drift.
The Three Decisions That Define a Drift Detector
Every drift detection setup, whether it is Evidently, NannyML, Arize, Fiddler, or a cron job you wrote yourself, reduces to three choices.
Reference window. What are you comparing against? The common options are a frozen snapshot of the training data or a trailing production window such as the last 30 days. Training-data references catch divergence from what the model actually learned; trailing references catch sudden change while tolerating slow seasonal movement. Many teams run both. Using the full training dataset is common but has a known weakness: training data is often preprocessed and filtered in ways that make it a poor proxy for live production traffic, while a rolling baseline can mask gradual drift by continuously shifting the reference point.
Comparison test. For each feature you need a way to score the gap between reference and current. Numeric features typically get a two-sample test or a distance metric; categorical features usually get a binned divergence such as PSI or Jensen-Shannon distance.
Aggregation. Per-feature results roll up into a dataset-level verdict, most commonly “share of features drifting,” plus an optional multivariate check. Univariate tests miss correlation changes. NannyML’s multivariate method fits PCA on the reference data (capturing about 65% of variance by default), reconstructs incoming batches through that compressed representation, and treats a rise in reconstruction error as drift. Their example makes the point vividly: rotate a 2D dataset 90 degrees and every univariate test stays green while the reconstruction error jumps.
For high-dimensional inputs like images or embeddings, the empirical evidence says reduce first, then test. The NeurIPS 2019 study Failing Loudly compared shift-detection pipelines across perturbation types and reported that two-sample testing on top of a learned dimensionality reduction, notably the softmax outputs of the pretrained classifier itself, detected shift best. The paper’s framing is the whole discipline in one phrase: models fail silently on out-of-distribution data unless you build the alarm yourself.
Statistical Tests for Drift Detection
Choose a statistic based on the feature type and the question. The Evidently comparison illustrates that methods can react differently to the same shift; its experimental results are not universal alert thresholds.
| Method | Typical input | What to inspect |
|---|---|---|
| KS two-sample test | Continuous values | Both the empirical-CDF distance and the sample-sensitive p-value |
| PSI | Fixed bins or category proportions | Bin definitions, smoothing, and the size of the distribution change |
| Wasserstein distance | Numeric values | Feature units and any normalization applied |
| Jensen-Shannon distance | Category or bin proportions | Consistent support, logarithm base, and implementation |
| Chi-square test | Categorical counts | Expected counts and treatment of rare categories |
SciPy’s KS reference defines the statistic and its hypothesis test. Statistical significance alone is not a measurement of prediction harm. Require enough observations for the intended test and choose an operationally meaningful effect threshold.
The PSI formula compares reference and current bin shares. Fix bins from the reference and document empty-bin handling. Conventional cutoffs are starting points to evaluate, not universal retraining rules. PSI vs CSI distinguishes a score-distribution check from the same calculation on each characteristic.
Raw Wasserstein distance uses the input feature’s units; it is not simply the change in the median. Normalized implementations rescale it, so record that definition before comparing columns. Jensen-Shannon is symmetric and finite where raw KL divergence can be undefined, but its numeric range depends on the logarithm base.
Separate effect size from the alert policy
Use choosing drift metrics: PSI, KS and calibration to distinguish distribution checks from outcome-quality checks. Even distance estimates vary with the sample and binning. Calibrate thresholds on representative stable windows and replay known incidents if available.
A dataset-level drifting-column share can summarize movement. Retain separate checks for critical features: a single broken required input can matter even when the aggregate share is small. Assign ownership and response severity in the ML model monitoring framework.
Detection Architecture in Production
Define the current window, reference version, model version, and transformation version before scheduling the job. Batch systems can compare complete periods; streaming systems require explicit choices about window size and the order in which observations arrive. Longer windows can hide a brief change by mixing it with unaffected traffic.
Segment the data where behavior or consequences differ. A dataset-wide distance can conceal movement within a product route, device type, or customer cohort. Check sample sufficiency within each segment as well as across the full dataset.
The current Evidently report example shows the data wrappers, report execution, and HTML/JSON exports. Use it as the implementation entry point; this page focuses on detector design. Evidently’s drift documentation explains its column-type and sample-size defaults. Persist the method and threshold with every result so reports remain comparable after a configuration change.
Compare the actual post-transformation features seen by the model. A production-versus-production baseline can miss a persistent mismatch with training. Add training-serving skew detection using matched inputs through both computation paths.
What to inspect after an alert
- One feature moves. Inspect its upstream source, encoding, missingness, and affected segments.
- Several related features move together. Check shared joins and transformations, then consider a changed population.
- Movement accumulates over successive windows. Compare with the fixed reference as well as a rolling one, and evaluate whether labeled performance has changed.
None of these patterns uniquely identifies a root cause. Retain deployment records and feature summaries with the alert to make the diagnosis reproducible.
When to Act on a Drift Signal
A drift alert should trigger one of three responses, not automatically a full retraining cycle.
Investigate first. Confirm the drift is real and not an artifact of a data pipeline issue: a schema change upstream, a missing feature value getting imputed differently, a change in how the feature is computed. Silent pipeline bugs and genuine distributional shifts produce identical statistical signatures.
Assess impact before retraining. If the drifting feature is not among the top contributors to model predictions (check feature importance or SHAP values), the drift may be ignorable in the short term. Trigger retraining when drift in high-importance features exceeds thresholds, not when any feature moves.
Rule out the other mechanism. Input drift and a changed feature-to-label relationship look nothing alike in their fix but similar on a dashboard. If accuracy is falling while these input tests stay flat, the detectors described here are the wrong instrument entirely and you want the error-rate and performance-estimation methods in concept drift detection: DDM, ADWIN, and Page-Hinkley instead.
Choose the retraining strategy. Evaluate recent labeled data after confirming its quality. A drift threshold can open a retraining evaluation; it should not by itself approve replacing the serving model.
Embedding-store reliability: monitor retrieval separately
An embedding store introduces a second question: whether approximate search is still returning the neighbors intended by the retrieval design. Availability and latency alone cannot answer it. Weaviate’s vector-index documentation describes how search parameters trade recall against speed.
Use a representative query sample with exact nearest-neighbor results over a specified corpus snapshot. Define ANN recall@k as the overlap between the approximate and exact top-k sets, divided by k, and aggregate across queries. Match filters, distance metric, and corpus version. This measures agreement with exact vector search, not human relevance or the correctness of the generated answer.
A suggested monitoring panel separates four failure classes:
| Failure class | Measurement | Diagnostic use |
|---|---|---|
| ANN recall regression | Recall@k against exact search | Compare index settings, corpus changes, and search parameters |
| Stale or mixed embedding versions | Encoder-version coverage and indexing backlog | Identify documents encoded with an incompatible model or awaiting refresh |
| Dimension or preprocessing mismatch | Vector length, norm distribution, distance metric | Compare ingestion and query encoder configurations |
| Corpus or query distribution change | Fixed-model embedding summaries and query-to-result similarity distributions | Locate changing topics or segments for relevance review |
Pinecone’s index setup documentation specifies the dimension and similarity metric when bringing vectors. Record the encoder and preprocessing version as additional application metadata. Equal dimensions alone do not establish compatibility. A changed norm distribution is a diagnostic clue; cosine similarity does not inherently require callers to supply unit-length vectors.
For an encoder migration, a conservative runbook is to prepare a separate index, backfill it, and check version coverage and retrieval quality before routing queries to it. Keep the prior encoder and index paired until cutover; retain them for rollback. Dual writes can keep both corpora current during the transition when the application supports that arrangement. These are proposed operating controls, not measured vendor guarantees.
Track a sampled query-to-result similarity histogram alongside the recall benchmark. A score-distribution shift can help locate a retrieval change but does not prove the results became less relevant. Recompute exact benchmarks when the corpus snapshot changes rather than comparing against obsolete neighbors.
Keep service telemetry too. Milvus documents monitoring with Prometheus and Grafana; those operational panels complement the retrieval-quality checks above. Carry encoder and index version IDs into outcome analysis so a failed answer can be traced to the retrieval version that supplied its context.
The distinction between retrieval degradation and generation quality is developed in monitoring tabular models vs LLM systems.
Caveats
Drift is not damage. Input movement can occur without lower accuracy, while quality can decline without detectable marginal input drift. Pair distribution checks with suitable outcome monitoring.
Binning changes the question. PSI needs consistent support and an explicit smoothing policy. High-cardinality identifiers may be better monitored through missingness, cardinality, and new-value rates than thousands of sparse bins.
Multiple comparisons need a policy. Testing many features repeatedly increases the chance of false alarms. Use statistical correction where appropriate, practical effect thresholds, and a selected set of actionable alerts. Multivariate checks complement marginal tests; neither replaces all the other checks.
Reference changes must be explicit. Keep a record of why the baseline was refreshed. A rolling window answers a different question from a fixed training reference and can conceal cumulative movement.
Putting It Together
A minimal viable drift detection pipeline needs four components: a reference dataset (training data or a stable production baseline), a statistical test matched to feature type and dataset volume, a windowed comparison on incoming production data, and an alerting layer that differentiates investigable drift from noise. Everything beyond that, including multivariate drift tests, segment monitoring, and automated retraining pipelines, is worth adding incrementally once the baseline is stable.