Sub topic 16
Responding to Skew: Triage, Rollback, Fix, Retrain
Assume you know basic Python, pandas, supervised learning, and how a model is deployed behind an API or batch job. This chapter focuses on what to do after monitoring shows a difference between training features and serving features.
A skew alert is evidence, not a diagnosis. First determine whether the difference is real, whether it affects important traffic, and whether it is harming predictions. Then choose the smallest safe response.
Triage the Alert
Start by checking the alert itself:
- Which feature changed?
- When did the change begin?
- Which model version and endpoint are affected?
- Is the change present for all requests or only one customer, region, or request type?
- Did the feature value change, or did only its distribution change?
- Are labels available to confirm an accuracy drop?
Compare recent serving logs with the exact training data and preprocessing configuration used by the deployed model. Check raw inputs, transformed features, missing-value rates, units, categories, and timestamps. A sudden value of zero may indicate a broken fallback. A gradual shift may reflect a real change in users.
Use a safe sequence:
flowchart TD
A[Skew alert] --> B[Confirm metric and scope]
B --> C{Customer impact or unsafe predictions?}
C -->|Yes| D[Rollback or disable traffic]
C -->|No| E[Investigate feature and data path]
D --> F[Fix root cause]
E --> F
F --> G[Run parity and validation tests]
G --> H{Does the fix pass?}
H -->|No| F
H -->|Yes| I[Canary release]
I --> J[Monitor and decide whether to retrain]Roll Back When Risk Is Immediate
Rollback means routing traffic to the last model or pipeline version known to work. Use it when skew can cause harmful decisions, severe accuracy loss, invalid outputs, or broad customer impact.
A rollback limits exposure, but it does not repair the data path. Keep the affected version available for investigation, preserve its logs, and record the exact deployment and configuration. If the old model also depends on the broken feature source, rollback alone will not help. In that case, disable the feature, switch to a safe default, or stop predictions until the input path is corrected.
Fix the Pipeline Before Retraining
Retraining is not a substitute for fixing skew. If production fills missing ages with zero while training uses a median, retraining on the same inconsistent paths teaches the model the wrong relationship again.
Common fixes include:
- Use one shared transformation for batch and online prediction.
- Bundle fitted imputers, scalers, and encoders with the model.
- Correct units, column names, category mappings, and timestamps.
- Add schema checks that reject impossible or unknown inputs.
- Rebuild training data with point-in-time-correct features.
- Add an offline/online parity test for every important feature.
After the fix, replay representative production requests through the corrected pipeline. Compare feature values, missingness, prediction distributions, and latency before releasing the model.
Decide Whether to Retrain
Retrain when the data has genuinely changed or the corrected feature behavior is materially different from the data used for training. Use recent, point-in-time-correct examples and compare the new model with the current model on a fixed validation set.
| Situation | First response |
|---|---|
| Broken transformation or schema | Fix pipeline and roll back if needed |
| Temporary upstream outage | Restore source or use an approved fallback |
| Permanent population change | Validate new data, then retrain |
| Unknown cause with customer risk | Roll back and investigate |
Retraining should follow, not replace, root-cause analysis.
Exercise
A feature's PSI rises sharply after a deployment, but labels are not available yet. What should you do first?
Show answer
Check the feature's raw and transformed values, missingness, schema, deployment version, and affected traffic. Roll back if the change creates unsafe or clearly invalid predictions; do not retrain before finding the cause.