Sub topic 4
What to Monitor: Inputs, Predictions, and Outcomes
Assume you already understand training, validation, deployment, batch or online serving, and basic Python and NumPy. This chapter focuses on the signals that tell you when a deployed model may need retraining.
A production model receives new inputs, produces predictions, and eventually may receive real outcomes. Monitor all three. Each provides different evidence about model health.
Monitor inputs
Input monitoring checks whether production data still resembles the data used for training. Track:
- Feature distributions, such as averages, percentiles, and category frequencies
- Missing-value rates
- Invalid values and schema changes
- The number of requests or rows
- Important segments, such as region, device type, or customer group
A change in an input distribution is called data drift. Drift does not always mean the model is failing. A feature may change while its relationship with the target remains stable. However, large or persistent changes should start an investigation.
Store a reference window from training or a known healthy period. Compare each production window with that reference.
| Signal | Example | Possible meaning |
|---|---|---|
| Missing-value rate | `12%` instead of `2%` | Upstream data failure |
| Category frequency | Mobile traffic doubles | Population or product change |
| Numeric distribution | Average income shifts | Data drift |
| Row count | 40% fewer events | Pipeline or traffic problem |
Monitor predictions
Prediction monitoring works even when labels are delayed or unavailable. Track:
- Prediction rates, such as approval or rejection percentages
- Numeric prediction summaries, such as mean and percentiles
- Classification confidence or probability distributions
- Output values by important segment
- Changes in the rate of fallback, timeout, or error responses
A sudden prediction shift can result from input drift, a serving bug, or a changed population. Compare prediction changes with input changes before deciding to retrain.
For example, a fraud model that suddenly marks 90% of transactions as suspicious may have a broken feature, a threshold configuration error, or genuine fraud growth.
import numpy as np
def prediction_summary(predictions):
values = np.asarray(predictions, dtype=float)
if values.size == 0:
raise ValueError("predictions must not be empty")
return {
"count": int(values.size),
"mean": float(values.mean()),
"p05": float(np.quantile(values, 0.05)),
"p50": float(np.quantile(values, 0.50)),
"p95": float(np.quantile(values, 0.95)),
}
print(prediction_summary([0.1, 0.2, 0.8, 0.9]))Monitor outcomes
Outcomes are the actual results that you want the model to predict. They may arrive hours or months after a prediction. Once they arrive, calculate performance metrics such as accuracy, precision, recall, error, or area under the ROC curve.
Join each outcome to its original prediction using a stable prediction ID. Also record the prediction timestamp, model version, feature or data version, and outcome timestamp. Without these fields, you cannot reliably compare models or determine whether recent labels belong to recent predictions.
Connect signals to action
Use dashboards and alerts for trends, not isolated events. A useful monitoring record includes the time window, model version, segment, metric, reference value, current value, and sample size.
A good trigger policy combines monitoring evidence with minimum sample sizes and operational checks. Do not retrain solely because one small segment produced an unusual value.
Exercise
Which signal can you monitor when labels have not arrived yet, and what should you avoid concluding from it?
Show answer
Monitor inputs and predictions. Avoid concluding that model performance changed without outcome labels, because prediction drift can come from population changes or serving errors.