Sub topic 1
Why models fail after deployment
A model that passed offline evaluation can still fail in production. This chapter explains the main reasons and the failure patterns you will see. Later chapters cover how to detect each one.
Prerequisites
This chapter assumes you have:
- Basic Python and NumPy.
- Experience training and evaluating a supervised model, including train/test splits and metrics such as accuracy or ROC AUC.
- Basic statistics: distributions, hypothesis tests and p-values.
- Some familiarity with serving a model as a batch job or an API.
Why offline results do not carry over
Offline evaluation answers one question: how well does this model predict on data drawn from the same source as the training data? It assumes the test set looks like the future. Production breaks that assumption in three ways:
- The data the model sees changes.
- The world the model describes changes.
- The pipeline that feeds the model breaks.
Each cause leaves different evidence, so each needs a different check.
Three families of failure
The input data changes
The population of users, devices or documents shifts. A fraud model trained on desktop traffic starts receiving mostly mobile traffic. The model still runs, and its inputs are valid. They are just unlike the training data, so its predictions are less reliable. This is data drift. It is often called covariate shift when only the inputs change.
The world changes
The relationship between inputs and the target changes. A model learned that a certain spending pattern signals fraud, and then fraudsters change tactics. The inputs may look the same as before, but the correct answer for them is different. This is concept drift. Input statistics alone cannot reveal it, because only the labels show the change.
The pipeline breaks
An upstream team renames a column, a sensor starts reporting temperature in Fahrenheit instead of Celsius, or a join starts returning nulls. No statistical subtlety is involved. The model receives wrong inputs and produces wrong outputs, often without raising an error.
The table summarizes the three families.
| Cause | What changes | Typical example | Visible without labels? |
|---|---|---|---|
| Data drift | Input distribution | New customer segment | Yes |
| Concept drift | Input-to-label relationship | Fraudsters adopt new tactics | No |
| Pipeline break | Input correctness | Unit change, null column | Yes |
Silent failure
Most production model failures are silent. A web service that crashes returns an error and someone is paged. A model that degrades keeps returning HTTP 200 with a plausible number. Nothing in standard infrastructure monitoring notices.
Labels add a second delay. In credit default or churn problems, the true outcome arrives weeks or months after the prediction. You may run a degraded model for a long time before accuracy metrics show it.
A concrete illustration
The sketch below trains a model on one distribution and evaluates it on data where the input has shifted. The model's accuracy falls even though no code changed.
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
rng = np.random.default_rng(0)
def make_data(n, shift=0.0):
x = rng.normal(shift, 1.0, size=(n, 1))
# The true boundary is nonlinear: class 1 when x is between 0 and 2.
y = ((x[:, 0] > 0) & (x[:, 0] < 2)).astype(int)
return x, y
X_train, y_train = make_data(5000)
X_test, y_test = make_data(5000)
X_shifted, y_shifted = make_data(5000, shift=2.0)
model = LogisticRegression().fit(X_train, y_train)
print("offline accuracy:", accuracy_score(y_test, model.predict(X_test)))
print("shifted accuracy:", accuracy_score(y_shifted, model.predict(X_shifted)))The model is only an approximation of a nonlinear rule, and it is accurate only in the region where it saw data. When inputs move to a region it handles poorly, accuracy drops. Real models behave the same way, though less dramatically.
What this means for monitoring
Because failures are silent, you need checks at several layers: service health, input quality, input and prediction distributions, and performance once labels arrive. The next chapter lays out those layers.
Exercise
A model's inputs look statistically identical to the training data, but its accuracy has dropped sharply. Which failure family is the most likely cause, and why can input monitoring not catch it?
Show answer
Concept drift. The relationship between inputs and the target has changed, so the same inputs now map to different correct answers. Input distributions stay the same, so only labels or performance metrics reveal the problem.
Exercise
An upstream team changes a price column from dollars to cents. The service keeps returning predictions with no errors. Name the failure family and one reason it goes unnoticed.
Show answer
A pipeline break. No exception occurs because the values are still valid numbers, so standard service monitoring sees nothing wrong. Only checks on input ranges or distributions would flag it.