الانتقال إلى المحتوى
Machine LearningMLOps· 7 دقائق للقراءة

A Deployed Model Doesn't Stay Accurate: Drift and Training-Serving Skew

The model file never changes. The world it learned from, and the pipeline that feeds it, do.

ReadIn

مقال كل يوم يفرق معاك

22 نوفمبر 2026
  • كاتب موثّق
محتويات المقال

A churn model launches with 0.807 accuracy on its holdout set. Every chart on the team's monitoring page stays green for a year: no exceptions, flat latency, every input's mean within a tenth of a standard deviation of training. Then an analyst joins the latest month of predictions with what customers actually did: 0.631. Nothing broke. The model kept answering, confidently, a question the world had stopped asking.

The common misconception

"Once a model is trained, validated and deployed, its accuracy stays the same." Engineers have good reasons to expect that:

  • Software doesn't rot: the same code with the same input returns the same output, and a model file is just as deterministic.
  • The validation score is measured once and written into the launch document, so it looks like a property of the model.
  • Decay is silent. A stale model throws no exceptions and still returns well-formed, confident predictions.

The half-truth: the model really doesn't change. But its accuracy was never a property of the model alone. It was a property of the model and the data of one period, delivered by one pipeline. Both of those keep moving.

What actually happens

A model encodes how the label depended on the inputs in its training data. Three things can pull production away from that picture.

The inputs drift

The mix of what arrives changes: new customer segments, a new app version, the seasons. Google's crash course gives a flower-shop model trained on July and August purchases that makes terrible predictions around Valentine's Day. A review of concept drift research by Lu and colleagues calls a change in the inputs alone, with the input-to-label rule intact, "virtual drift": the decision boundary stays where it was. It's a warning sign, not a verdict, because the model may or may not have learned that region well.

The rule itself drifts

Sometimes the same inputs start leading to different outcomes: fraudsters adapt, a competitor cuts prices, a policy changes. The review calls this actual drift, because it moves the decision boundary and accuracy falls. It can arrive suddenly, gradually, incrementally, or as a recurring pattern such as seasons. Google's static-vs-dynamic training page puts it simply: if the relationship between features and labels changes over time, your model's predictions will degrade.

This is the in the opening story, and the first script reproduces it: the inputs stay put, the rule slowly changes, and the model is trained once. The second script measures each month on fresh labels and retrains on the latest month.

Python
import numpy as npfrom sklearn.linear_model import LogisticRegressionrng = np.random.default_rng(0)def month(m, n=2000):  # month m of traffic: the inputs look the same,    X = rng.normal(size=(n, 3))  # but the rule behind the label drifts    y = X @ [1.0, -1.0, 0.5 - 0.15 * m] + rng.normal(size=n) > 0    return X, yX_train, y_train = month(0)model = LogisticRegression().fit(X_train, y_train)  # trained onceprint(f"Launch: holdout accuracy {model.score(*month(0)):.3f}")for m in range(1, 13):    X, y = month(m)    shift = np.abs(X.mean(axis=0) - X_train.mean(axis=0)).max()    if m % 3 == 0:  # the input dashboard stays green all year        print(f"Month {m:>2}: input shift {shift:.2f} sd, "              f"accuracy {model.score(X, y):.3f}")# Launch: holdout accuracy 0.807# Month  3: input shift 0.07 sd, accuracy 0.776# Month  6: input shift 0.03 sd, accuracy 0.726# Month  9: input shift 0.02 sd, accuracy 0.680# Month 12: input shift 0.06 sd, accuracy 0.631

No input moved by more than 0.07 standard deviations all year, so a dashboard of input statistics saw nothing, while accuracy slid from 0.807 to 0.631. Only labels reveal a change in the rule. With monthly retraining, the model scored between 0.808 and 0.843 on every new month. In real systems labels arrive late, a month for churn or weeks for fraud chargebacks, so this measurement always runs behind; plan for the lag.

Training-serving skew: the drop that isn't drift

Some decay happens on day one. Google defines as input data during serving that differs from the data during training. Schema skew means the two don't follow the same schema; feature skew means the feature engineering code differs between the two, so the same raw row produces different features: a duration in seconds offline and milliseconds online, a missing value filled with 0 in one place and the mean in the other.

The Rules of Machine Learning give a way to locate it (rule #37): compare performance on training data with holdout data, holdout with "next-day" data, and next-day with live data. A gap between next-day and live data points to an engineering bug, since the same example should score the same in both.

Kind of decayWhat changesHow you see itWhat to do
Input driftThe mix of inputsInput statistics against trainingInvestigate; retrain if accuracy follows
Concept driftHow inputs map to the labelAccuracy on fresh labelsRetrain on recent data, more often
Training-serving skewThe pipeline: same row, different featuresLogged serving features against training featuresFix the code; share it between both paths
StalenessNothing visible, just ageAn alert on model ageA retraining schedule based on freshness needs

How to apply it in your project

  1. Decide how fresh the model must beRule #8 asks how much quality you lose with a model that is a day, a week or a quarter old. The answer sets the retraining schedule and a threshold age for alerts.
  2. Monitor the inputsCheck serving data against the schema and against training statistics: missing-value rates, means, category frequencies. It's cheap, needs no labels, and catches skew and input drift.
  3. Join predictions with outcomesWhen labels arrive, compute the model's real metric per week or month, and alert on both sudden drops and slow slides.
  4. Share code and log serving featuresUse the same feature code for training and serving, log what the model saw, and measure the next-day-to-live gap.
  5. Retrain, then compare before you promoteRetrain on recent data, validate against the current model on fresh data, and keep the old model ready to roll back.

Key takeaways

  • A model's accuracy belongs to the model plus the data and pipeline of its training period, and those keep changing.
  • Concept drift can leave the inputs unchanged: here no input moved more than 0.07 standard deviations while accuracy fell from 0.807 to 0.631.
  • Measuring on fresh labels and retraining on recent data kept the same model family between 0.808 and 0.843.
  • Training-serving skew is a bug, not drift: log serving features, share feature code, and compare next-day and live performance.

📚 المصادر

  1. Production ML systems: Monitoring pipelines — Google Machine Learning Crash Course
  2. Production ML systems: Static versus dynamic training — Google Machine Learning Crash Course
  3. Rules of Machine Learning (rules #8, #29, #32 and #37) — Google for Developers
  4. Learning under Concept Drift: A Review — Lu et al. (arXiv)

التعليقات (0)