Monitoring, Drift and Model Maintenance
Detect when production data or model quality drifts away from what you trained on, and decide when to retrain.
Advanced · about 6 hours · difficulty 3/5
Learn first: Serving Models with FastAPI and BentoML, Statistics for Data Science
A model's accuracy on launch day is its best day. Customer behaviour shifts, upstream pipelines change, and the world moves on. Without monitoring you learn about it from angry users.
What can go wrong
- Data drift (covariate shift): input distributions change, for example a new user segment.
- Concept drift: the relationship between inputs and target changes, for example fraud patterns adapt.
- Label shift: the class balance moves.
- Data quality bugs: a column becomes all nulls, units change, a category is renamed.
- Training-serving skew: features are computed differently online than in training.
What to monitor
- Operational: latency, error rates, throughput, resource use.
- Inputs: null rates, ranges, category frequencies, and drift statistics such as PSI, KL divergence or Kolmogorov-Smirnov tests.
- Outputs: prediction distribution and confidence.
- Quality: real metrics once labels arrive; use proxies (click-through, complaints) while you wait.
Tools and practice
Log every request and prediction with a model version. Evidently, WhyLabs or NannyML compute drift reports; Prometheus and Grafana handle dashboards and alerts. Set alert thresholds carefully: drift in an unimportant feature is noise. Decide in advance whether retraining is scheduled, triggered by drift, or triggered by a drop in measured quality, and keep humans in the loop for high-stakes models.
Good enough to move on when your deployed model has dashboards and alerts for inputs, outputs and latency, and you have a written plan for what happens when an alert fires.
Key concepts
- Data drift vs concept drift
- Training-serving skew
- Drift statistics (PSI, KS test)
- Prediction and label logging
- Evidently reports
- Prometheus and Grafana alerts
- Retraining strategies
Mini project
Simulate drift by replaying a dataset in time order through your served model, log inputs and predictions, generate Evidently drift reports per week, and trigger an alert and retraining job when PSI crosses a threshold.
Check yourself
How would you tell data drift apart from concept drift, and why can you detect one before labels arrive but not the other?
Free resources
- Evidently documentation (Evidently AI)
- Made With ML (Made With ML)
- Prometheus documentation (Prometheus)