Sub topic 4
What to monitor: inputs, predictions, and outcomes
This chapter assumes you can train and serve a model, know the difference between batch and online serving, and can read short Python and NumPy. It covers which signals to collect from a deployed model. The later chapters on drift statistics and performance triggers use those signals to decide when to retrain.
Three places to look
A deployed model sits between data going in and decisions coming out. You can measure three things:
- Inputs: the feature values the model receives at serving time.
- Predictions: the scores, classes, or values the model returns.
- Outcomes: the ground truth that arrives later, such as whether the customer defaulted or the user clicked.
These differ in speed and in what they can tell you. Inputs and predictions exist the moment a request is served. Outcomes can take hours, weeks, or months. A pipeline that watches only outcomes reacts late. A pipeline that watches only inputs reacts early but cannot tell whether a change actually hurt the model.
| Layer | Example signals | Available | What it catches | What it misses |
|---|---|---|---|---|
| Inputs | Missing rate, mean, std, category frequencies, schema violations | Immediately | Broken upstream pipelines, data drift | Changes that do not affect the model's accuracy; concept drift |
| Predictions | Mean score, positive rate, score histogram, latency | Immediately | Shifts in model behavior, silent failures such as constant outputs | Whether the predictions are right |
| Outcomes | Accuracy, AUC, calibration, business metric | Delayed | Real quality loss, including concept drift | Anything that has not yet been labeled |
Inputs
Input monitoring compares recent serving data with a reference, usually the training or validation set. Collect these per feature and per time window:
- Missing rate and null handling. A jump in missing values usually means a broken upstream join, not a changed world.
- Location and spread. Mean, standard deviation, and a few quantiles for numeric features.
- Category frequencies. Share of each category and the rate of unseen categories.
- Schema and range checks. Type, units, and allowed ranges. A feature that switches from dollars to cents passes a schema check but ruins the model.
Many input changes are bugs, not drift. Separate the two in your alerts. A bug calls for a fix and often a rollback of the data pipeline. Retraining on bugged data makes things worse.
Predictions
Prediction monitoring needs no labels, so it is a cheap early warning. Track the mean score, the positive rate at your decision threshold, and the shape of the score distribution. A fraud model whose flag rate falls from 2% to 0.3% overnight has changed behavior, whatever the cause.
Also log what you need to reproduce a prediction: model version, feature values or a pointer to them, timestamp, and a unique prediction ID. Without the ID you cannot join outcomes later. Without the model version you cannot tell whether a change came from new data or from a new model.
Outcomes
Outcomes give the only direct measure of quality. You join each logged prediction to its eventual label, then compute the metric you care about on the matched rows. Three details matter:
- Coverage. Report the fraction of recent predictions that have a label. A metric computed on 5% of rows may be biased, because the labels that arrive first are often not representative.
- Selection bias. If a prediction changes what you observe, the outcomes are skewed. A loan model only sees repayment for approved applicants.
- Window choice. Compute metrics per prediction date, not per label arrival date, so a slow label stream does not blur the comparison.
The delay itself, and what to do about it, is the subject of the performance-trigger chapter.
A small monitoring job
This script computes input and prediction summaries for one window, then joins partial outcomes and reports label coverage along with accuracy on the matched rows.
import numpy as np
def summarize_window(features, scores, threshold=0.5):
"""Per-feature and per-score summaries for one serving window."""
scores = np.asarray(scores, dtype=float)
summary = {"rows": len(scores)}
for name, values in features.items():
values = np.asarray(values, dtype=float)
summary[f"{name}.missing_rate"] = float(np.isnan(values).mean())
summary[f"{name}.mean"] = float(np.nanmean(values))
summary[f"{name}.std"] = float(np.nanstd(values))
summary["score.mean"] = float(scores.mean())
summary["positive_rate"] = float((scores >= threshold).mean())
return summary
def outcome_metrics(pred_ids, scores, outcomes, threshold=0.5):
"""Join predictions to the outcomes that have arrived so far.
outcomes maps prediction ID to the true label (0 or 1).
"""
matched = [
(int(score >= threshold), outcomes[pid])
for pid, score in zip(pred_ids, scores)
if pid in outcomes
]
coverage = len(matched) / len(pred_ids)
if not matched:
return {"label_coverage": 0.0, "accuracy": None}
accuracy = float(np.mean([pred == label for pred, label in matched]))
return {"label_coverage": coverage, "accuracy": accuracy}
rng = np.random.default_rng(0)
n = 1_000
amount = rng.lognormal(3.0, 0.5, n)
amount[rng.random(n) < 0.02] = np.nan
scores = rng.beta(2, 5, n)
pred_ids = list(range(n))
outcomes = {i: int(rng.random() < scores[i]) for i in range(400)}
summary = summarize_window({"amount": amount}, scores)
print({k: round(v, 3) for k, v in summary.items()})
print(outcome_metrics(pred_ids, scores, outcomes))In this run, only 400 of the 1,000 predictions have labels, so label_coverage is 0.4. Read the accuracy together with that number.
Choosing what to alert on
Monitoring everything produces alerts nobody reads. A practical approach:
- Alert on data-quality signals (missing rate, schema) as warnings that block training on bad data.
- Treat input and prediction shifts as candidates for a retraining trigger, not as automatic triggers. A shift only matters if it plausibly affects quality.
- Treat outcome degradation as the strongest evidence, and the usual justification for retraining.
- Set thresholds from history. Look at a few weeks of normal variation, including weekday and seasonal patterns, before choosing a limit.
Common errors
- Logging features after preprocessing in the serving code but comparing them with raw training data. Compare like with like.
- Forgetting to log the prediction ID, which makes outcome joins impossible later.
- Comparing windows of different sizes or seasons, such as a holiday week against a normal month.
- Computing outcome metrics only on easy or early-arriving rows and reporting them as the model's quality.
Exercise
A churn model's input feature distributions look unchanged and the positive prediction rate is stable, yet the business team says retention campaigns based on the model work worse than last quarter. Which monitoring layer should reveal the problem, and what is the likely cause?
Show answer
The outcome layer. Joining predictions to later churn labels and computing a metric such as AUC or precision per prediction month should show the decline. Because inputs and predictions look stable, the likely cause is concept drift: the relationship between the features and churn changed, for example after a pricing change or a new competitor. You should also check label coverage and selection bias, since campaigns change who churns.