Sub topic 14
Revisiting baselines after deployment
A baseline is chosen at one moment, against one dataset, one metric, and one set of requirements. After deployment, all four can change. This chapter covers how to keep the baseline comparison valid over time and how to use it to decide whether to retrain, simplify, or retire a model.
This chapter assumes you can do the following:
- Fit scikit-learn estimators and compute metrics such as mean absolute error (MAE).
- Read the repeated cross-validation and good-enough checks from earlier chapters.
- Work with NumPy arrays.
Why a baseline goes stale
A baseline score is a measurement, not a constant. The statement "the model beats the median predictor by 1.0 MAE" was true for the data you tested on. Four things can break it after launch.
- The data distribution shifts. Input features change in range or frequency, for example a new customer segment or a new sensor firmware.
- The relationship between features and label shifts. This is concept drift. The same inputs now lead to different outcomes.
- The existing system changes. If your baseline is a rule or a legacy system, someone may improve it or replace it. Your "gain" is then measured against a system that no longer exists.
- The requirements change. The minimum useful gain, the cost of a false negative, or the latency budget may move. A model that was good enough can stop being so without any change in its accuracy.
The first two change the model's score. The last two change the meaning of the score.
Keep a baseline running next to the model
The cheapest protection is to keep scoring a simple baseline on the same live data as the model. Then every monitoring report gives you a paired comparison, as in the offline evaluation.
Compare the following two situations.
| Monitoring only the model | Monitoring model and baseline |
|---|---|
| MAE rises from 0.8 to 1.2. | MAE rises from 0.8 to 1.2, and baseline MAE stays at 1.8. |
| You cannot tell whether the task got harder or the model broke. | The gap shrank but the model still helps. The model is degrading, not failing. |
| Both models' errors rising together may mean noisier labels. | If both rise together, the task itself probably got harder. |
Run the baseline in shadow mode: it computes predictions on the same inputs but never serves them. Trivial baselines (constant, previous value) cost almost nothing. A simple model baseline such as a linear model needs retraining on a schedule, so budget for that.
A paired check on a rolling window
The offline good-enough check used paired differences and a minimum useful gain. Apply the same idea per time window. The example below simulates a model trained when the true slope was 2.0. At week 10 the slope drops to 0.3, and the deployed model keeps predicting with 2.0. The baseline is a constant prediction of zero, standing in for the training median.
import numpy as np
rng = np.random.default_rng(0)
n_weeks, per_week = 20, 200
# Concept drift: the true slope falls from 2.0 to 0.3 at week 10.
X = rng.normal(size=(n_weeks, per_week))
slope = np.where(np.arange(n_weeks) < 10, 2.0, 0.3)[:, None]
y = slope * X + rng.normal(scale=1.0, size=(n_weeks, per_week))
model_pred = 2.0 * X # deployed model, frozen since training
baseline_pred = np.zeros_like(X) # constant baseline
mae_model = np.abs(y - model_pred).mean(axis=1)
mae_base = np.abs(y - baseline_pred).mean(axis=1)
# Positive gain means the model beats the baseline (lower MAE).
gain = mae_base - mae_model
min_useful_gain = 0.3 # same threshold used at launch
below = gain < min_useful_gain
for week in range(1, n_weeks):
if below[week] and below[week - 1]:
print("alert: gain below threshold two weeks running, week", week)
break
for week in (0, 9, 10, 11, 19):
print(week, round(gain[week], 2))The alert fires at week 11, the second consecutive week below the threshold. After the drift the gain is negative: the frozen model is now worse than predicting a constant. A dashboard that showed only the model's MAE would show a rise, with nothing to say whether the rise matters.
Two design choices in this check are worth copying.
- Two consecutive windows trigger the alert. One bad week may be noise. Weekly scores have the same sampling variance you saw in the uncertainty chapter, and a single window of 200 rows is a small sample.
- The threshold is the one set at launch. It comes from the product requirement, not from whatever the model currently achieves. Changing it after the fact to silence an alert defeats its purpose.
Delayed and biased labels
Live monitoring needs ground truth, and ground truth often arrives late or incompletely.
- Delay. A loan default label may take a year. Until labels arrive, you can only monitor inputs and prediction distributions. Score the model against the baseline on the cohorts whose labels have matured, and accept that your estimate describes the past.
- Selection bias. If the model's decisions determine which outcomes you observe, the labelled data is no longer a random sample. A fraud model that blocks transactions never learns whether the blocked ones were fraud. Hold out a small random slice that is exempt from the model's decision, and score both model and baseline on it.
- Feedback loops. Predictions that influence future labels can inflate the model's apparent accuracy. The random holdout slice protects against this too.
When to refresh the baseline itself
Re-running a stale baseline protects you from drift in the model. It does not protect you from a baseline that was weak to begin with. Revisit the baseline in these cases:
- A better simple model becomes cheap. New features, more data, or a library upgrade may let a linear model or shallow tree close most of the gap. Retrain it on the current data and recompute the gain.
- The legacy system was replaced or tuned. Re-measure it. Gains reported against the old version should be labelled as such.
- The task definition changed. A new label definition, a new class, or a new metric means all earlier comparisons no longer apply. Rebuild the trivial baselines from scratch and re-run the comparison.
- The model has been serving for a long time. Even without an alert, re-run the full offline comparison on a recent held-out period once or twice a year, using the same repeated cross-validation setup as at launch.
Record the baseline version, data window, metric, and seed alongside each score. A gain without these is not reproducible, and you will not be able to tell later whether a change came from the model or from the comparison setup.
Deciding what to do with the result
The monitoring result leads to one of a few actions. The gain relative to your good-enough threshold, and the cost of acting, decide which.
The "switch to the baseline" branch is easy to overlook. If the gain has fallen to near zero and the model costs more to run and maintain, retiring it is a legitimate outcome. The cost trade-offs chapter applies here in reverse: complexity that no longer pays for itself should go.
Common errors
- Comparing against an old score. Reporting today's model score against the baseline score from launch mixes two different data periods. Re-score both on the same recent window.
- Alerting on the model's score alone. A rising error may reflect a harder period, and a stable error may hide a collapsing gain if the baseline improved. Alert on the paired gain.
- Retraining without re-checking the baseline. After retraining, evaluate the new model against the current baseline on a held-out recent period. Do not assume the retrained model is better because it saw newer data.
- Tuning the threshold to the alert. Revise the minimum useful gain only when the requirement itself changes, and record who changed it and why.
- Ignoring slices. An average gain can hold while a segment collapses. Run the slice evaluation from the error analysis chapter on recent data as well.
Exercise
A deployed churn model had an F1 of 0.62 against a majority-class baseline F1 of 0.0 at launch. Six months later the model's F1 on newly labelled data is 0.55, and a retrained logistic regression baseline scores 0.54 on the same rows. The minimum useful gain agreed with the product team was 0.05 F1. What does this tell you, and what should you do?
Show answer
The model's gain over the strongest simple baseline is 0.55 - 0.54 = 0.01, below the 0.05 minimum. The original comparison against the majority-class baseline was too weak to show this. The drop from 0.62 to 0.55 may be drift or noise, but the paired gain over a current simple model is what matters. Check the uncertainty of the 0.01 difference on the same rows. If it stays below 0.05, the model is no longer justified by its added complexity. Either retrain it and re-check the gain, or switch to the logistic regression, which is cheaper to maintain and performs almost as well.