Ultralytics YOLO27: Join the waitlist.
License YOLO
Back to Ultralytics Glossary

Data Drift

Data drift is a shift in production input data away from the training distribution that erodes accuracy. Drift types, statistical tests, and retraining.

Data drift is a change in the statistical distribution of the input data a deployed model receives, relative to the data it was trained on. Models assume that production inputs come from the same distribution as their training data, and when that assumption breaks, accuracy can fall with no error message and no change to the model's code or weights. Common causes in vision systems include new cameras or lenses, changes in lighting and seasons, a moved camera angle, new product packaging, and upstream pipeline changes such as a different image compression setting. Detecting and responding to drift is a core task of model monitoring and machine learning operations (MLOps).

Types of Distribution Shift#

A classifier models the probability of a label given an input, and the shift can occur in the inputs, the labels, or the relationship between them:

  • Covariate shift: The input distribution changes while the correct label for any given input stays the same. A detector trained on daytime images that starts receiving dusk footage faces covariate shift, because a car is still a car. Data drift in the narrow sense means this case.
  • Label shift: Also called prior probability shift, the class frequencies change. If a production line's defect rate rises from 1% to 5%, the share of a detector's alarms that are real rises with it, so its precision changes even though the model and the look of each defect are unchanged.
  • Concept drift: The relationship between inputs and labels changes, so the same input now deserves a different label. Fraud patterns evolve as fraudsters adapt, and a quality standard that tightens turns parts once accepted into rejects.

Drift can be sudden, such as a camera replacement, gradual, such as lens dirt building up, or recurring, such as seasonal foliage and snow.

Detecting Data Drift#

Drift detection compares a reference sample, usually the training or validation data, with a recent window of production data. Without labels, teams test whether the two input distributions differ, using the two-sample Kolmogorov-Smirnov (KS) test for continuous features, a chi-squared test for categorical ones, or the population stability index (PSI) common in credit scoring. Raw pixels are too high-dimensional to compare directly, so image monitoring tests summary statistics such as brightness and sharpness, or the embeddings of a pretrained network; a study of shift-detection methods found two-sample tests on representations from pretrained classifiers worked best. The model's own outputs are a second signal: shifts in predicted class frequencies, boxes per image, or confidence scores often appear before anyone measures accuracy.

import numpy as np
from scipy.stats import ks_2samp

rng = np.random.default_rng(0)

# Mean brightness (0-255) of 500 training images and two batches of 200 production images
reference = rng.normal(130, 25, 500)
same_light = rng.normal(130, 25, 200)
dusk = rng.normal(110, 25, 200)

# Two-sample Kolmogorov-Smirnov test: a small p-value means the distributions differ
for name, batch in (("same light", same_light), ("dusk", dusk)):
    result = ks_2samp(reference, batch)
    drifted = result.pvalue < 0.01
    print(f"{name}: KS statistic {result.statistic:.3f}, p-value {result.pvalue:.2g}, drift {drifted}")

The batch drawn from the training distribution scores a KS statistic of 0.046 with a p-value of 0.91, and the batch whose mean brightness fell by 20 levels scores 0.346 with a p-value of 1.1e-15 and is flagged. The KS statistic is the largest gap between the two cumulative distributions, and with very large samples even harmless shifts reach tiny p-values, so drift alerts are often set on the KS statistic itself, which measures the size of the shift, instead of the p-value alone.

Responding to Drift#

Only fresh labels show whether a detected shift has lowered accuracy. The standard response is to sample recent production data, label it, measure mean average precision (mAP) or other task metrics on it, and retrain or fine-tune on a mix of new and original data when performance has dropped, keeping old examples in the mix to avoid catastrophic forgetting. Data augmentation such as brightness, blur, and color changes prepares a model for variation that can be anticipated, and unsupervised domain adaptation adjusts a model to a new domain with unlabeled target data. On Ultralytics Platform, the Monitoring tab of a dedicated endpoint charts mean prediction confidence over time, class counts, and box sizes and locations for the images it serves, and recent examples can be saved to a dataset for review and retraining.

  • Model drift: The decline in a model's performance over time, the effect that data drift and concept drift cause. Also called model decay.
  • Training-serving skew: A mismatch between training and production data caused by different processing in the two pipelines, such as another resize method, present from the first day of deployment rather than developing over time.
  • Anomaly detection: Flags individual inputs that differ from the norm, such as a single corrupted frame. Drift detection compares whole distributions and flags a week of uniformly darker images.
  • Out-of-distribution (OOD) detection: Scores each input for how unlike the training data it is, usually so the model can abstain or defer to a person on that input.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning