Sub topic 13
The evaluation gate: champion versus challenger
This chapter assumes you know the basic train, validate, test workflow, can read short Python and NumPy, and understand that a retraining pipeline produces a new model file after a trigger fires. Earlier chapters covered the triggers and data validation. Here we cover the step that decides whether the new model replaces the current one.
What the gate does
A retraining pipeline produces a challenger, which is a newly trained model. The model currently serving traffic is the champion. The evaluation gate is an automated check that compares the two and decides whether the challenger may move on to the registry and rollout.
Retraining does not guarantee a better model. A challenger can be worse because of a bad data slice, a subtle bug in feature code, or a lucky champion. Without a gate, every trigger becomes a deployment of unknown quality. With a gate, most bad retrains die quietly in the pipeline.
The gate sits between training and registration.
Rule 1: fail closed on data problems
The gate should not look at metrics at all if the data checks failed. A model trained on corrupted data can still score well on a corrupted validation set. The first line of the gate therefore checks the result of data validation and rejects the challenger if it failed.
Rule 2: compare on the same data
A fair comparison scores both models on the same evaluation set. Common mistakes:
- Using the champion's number from its original training run. That number came from an older dataset, so the difference mixes model quality with data change.
- Using a validation set that overlaps with the challenger's training rows. The challenger then looks better because it has seen the answers.
- Using a stale evaluation set. If the world has drifted, the old set rewards the old model.
A practical setup is to hold out the most recent window of labeled data, train the challenger on data before that window, and score both models on the window. Re-score the champion each time instead of reading a stored value.
Rule 3: require a minimum gain, allow a bounded regression
The gate in the topic's example code has three outcomes: data checks failed, regression, or gain below threshold.
def should_promote(challenger_auc, champion_auc, challenger_data_ok,
min_gain=0.002, max_regression=0.0):
"""Promote only if data checks passed and the challenger is not worse."""
if not challenger_data_ok:
return False, "data_validation_failed"
delta = challenger_auc - champion_auc
if delta < -max_regression:
return False, "regression"
if delta < min_gain:
return False, "gain_below_threshold"
return True, "promote"
print(should_promote(0.912, 0.905, True))
print(should_promote(0.903, 0.905, True))The first call prints (True, 'promote') because the gain is 0.007. The second prints (False, 'regression') because the challenger is 0.002 below the champion.
The two thresholds do different jobs:
min_gainstops churn. Every deployment has a cost and a risk, so a gain of 0.0001 AUC is not worth it. It is also below the noise level of most evaluation sets.max_regressionsets how much loss you tolerate. Zero means never accept a worse model. A small positive value is useful when the champion is badly out of date and you accept a slight drop on the old metric for better coverage of new data. Use it with care and with a human approval step.
Note that these two thresholds interact. If max_regression is positive, the regression check lets small drops through, and then min_gain still blocks them because a negative delta is below min_gain. In this function, a positive max_regression therefore has no practical effect unless you also lower min_gain below zero. Decide on one clear policy, and test it.
Rule 4: account for noise
A single AUC difference on a finite evaluation set is an estimate. Two identical models trained with different random seeds usually differ in the third decimal place. Ways to reduce false promotions:
- Use a bootstrap. Resample the evaluation set many times, compute the difference each time, and require the lower end of a confidence interval (for example the 5th percentile) to exceed
min_gain. - Train with a fixed seed so that reruns are repeatable, and compare against a baseline built the same way.
- Make the evaluation set large enough. If your gain threshold is 0.002, an evaluation set of a few hundred rows cannot resolve it.
Rule 5: look beyond one number
An aggregate metric can hide damage. A challenger can improve overall AUC and fail badly for one region or customer segment. Add these checks to the gate:
| Check | What it catches |
|---|---|
| Per-slice metrics (region, device, new versus returning users) | Regressions hidden by a large majority group |
| Calibration (for example expected calibration error) | Scores that rank well but no longer match true probabilities, which breaks threshold-based decisions |
| Latency and model size | A model that is accurate but too slow or too large to serve |
| Prediction distribution against the champion | Sudden shifts in the share of positive predictions |
| Fairness or business constraints | Rules that must hold regardless of accuracy |
Define each as a pass/fail rule, so the gate result is a list of named reasons. When a gate rejects a model, an engineer reading the log should see which rule failed.
Edge cases
- No champion yet. On the first run there is nothing to compare against. Compare to a simple baseline, such as a majority-class predictor or a previous rule-based system, and require human approval.
- Label delay. If labels arrive weeks late, the most recent window has no labels. The gate then evaluates on older data, which may not represent current traffic. Consider adding a shadow comparison on unlabeled live traffic before full promotion.
- Champion is degraded by drift. Scoring the champion on fresh data may give a low number. That is correct: the gate should compare the two on today's data, not on the day the champion was trained.
- Tiny gains with large cost. If retraining is expensive, set
min_gainhigher so the pipeline does not pay for models it will discard. - Feedback loops. If the champion's predictions affect which labels you collect, the evaluation set is biased toward the champion's choices. Keep a small random-exploration sample to evaluate fairly.
Record the decision
The gate should write a structured record: both model versions, the data version, each metric, each rule result, and the final reason. This record becomes part of the lineage and lets you answer "why did we not ship the retrain from last Tuesday?" without rerunning anything.
Exercise
A challenger has AUC 0.9081 and the champion has AUC 0.9070 on the same recent evaluation window. The gate uses mingain=0.002 and maxregression=0.0, and data validation passed. What does should_promote return, and what extra check would you add before trusting a promotion at this margin?
Show answer
It returns (False, "gainbelowthreshold") because the delta is 0.0011, which is not below zero but is below 0.002. Even if the gain were above the threshold, a difference this small can be noise, so add a bootstrap confidence interval on the metric difference and require its lower bound to exceed min_gain. Also check per-slice metrics so the small average gain does not hide a regression in one segment.
Exercise
Why must the gate re-score the champion on the current evaluation set instead of using the metric stored when the champion was trained?
Show answer
The stored metric was computed on older data. If the data has drifted, the champion's score on current data is probably lower, and the challenger's score is on current data. Comparing the two numbers mixes the effect of model quality with the effect of the data change. Both models must be scored on the same recent set for the comparison to be fair.