5.3.11 · D2MLOps & Deployment

Visual walkthrough — CI - CD pipelines for ML

2,778 words13 min readBack to topic

Prerequisite links you may want open while reading: the parent pipeline, Statistical Significance, A-B Testing & Canary Deployment, Model Monitoring.


Step 1 — What is a "score" really?

WHAT we did: defined the number that ranks two models. WHY: the whole gate is a comparison of two scores, so the score must be pinned down first. PICTURE: below, each test example is one tile. Green tiles = correct, amber = wrong. The score is just the green fraction.

Figure — CI - CD pipelines for ML

Step 2 — The trap: a score is a sample, not the truth

WHAT we did: separated the fixed truth from the wobbling measurement . WHY: if we forget wobbles, we'll mistake a wobble for a real improvement — the exact bug the margin fixes. PICTURE: the same model tested three times on three different held-out sets gives three different scores scattered around the true .

Figure — CI - CD pipelines for ML

Step 3 — How big is the wobble? Enter the standard error

Each test example is like flipping a biased coin: heads (correct) with probability , tails (wrong) with probability . We flip it times and take the fraction of heads. Statisticians long ago worked out how much such a fraction wanders.

PICTURE: the wobble-width gets narrower as grows. Watch the bell squeeze inward.

Figure — CI - CD pipelines for ML

Step 4 — Turning wobble into a decision distance (both models wobble!)

We have two models: incumbent score and challenger score . Their gap is

The subtle point the naive version misses: both scores wobble, so their difference wobbles more than either one alone. If two independent measurements each have variance , their difference has variance (variances of independent quantities add). Taking the square root:

  • ::: the wobble of the gap, not of one score.
  • When the two scores are close (so ), this becomes — the difference is about times noisier than a single score.

PICTURE: the null wobble of the gap is a bell centred at with width . The amber gain must land in the far tail.

Figure — CI - CD pipelines for ML

Step 5 — Naming the margin (and how to actually compute it)

Rearrange back into the promotion form. Recall :

Simplified rule of thumb. When both models sit at roughly the same rate on the same test set, , so The parent note's headline is the loose, conservative-in-the-other-direction version — fine as a first cut, but the factor above is the honest noise of a difference.

WHAT we did: defined from the gap's noise and showed how to fill in from data. WHY: only now is every symbol in the boxed gate grounded in a picture and a computation. PICTURE: the incumbent score is a line; is a shaded amber "safety cushion" stacked on top; only scores above the cushion promote.

Figure — CI - CD pipelines for ML

Step 6 — Reading the knobs: what makes big or small?

PICTURE: a curve of against (falling) and a second against (a dome peaking at ).

Figure — CI - CD pipelines for ML

Step 7 — Edge & degenerate cases (never leave a gap)

PICTURE: four mini-panels, one per case, each showing what the gate does.

Figure — CI - CD pipelines for ML

Step 8 — Plugging in the worked numbers

Parent Example 1: , , challenger . First check the CLT condition: and ✅ — the bell-curve ruler is valid.

Single-score noise (plug in ):

Parent's loose rule ():

Honest difference-noise rule (, since both models wobble on the same set, treated as independent for safety):

  • ::: one single-score noise-width on 2500 points.
  • vs ::: the parent's optimistic cushion vs the correct difference-aware cushion.
  • Lesson: the naive gate would have shipped a model whose gain is within the true noise of a difference. A proper paired McNemar test (or a canary rollout, see A-B Testing & Canary Deployment) is the safe call here.

PICTURE: the number line with , both cushions ( and ), and the challenger landing between them.

Figure — CI - CD pipelines for ML

The one-picture summary

Figure — CI - CD pipelines for ML

This single diagram compresses the whole walkthrough: a wobbling measurement around a hidden truth , a noise ruler built from that wobble, the difference ruler , a cushion stacked on the incumbent, and the automatic switch that fires only when the challenger clears the cushion.

Recall Feynman retelling — the whole story in plain words

A model's "score" is like a batting average measured over a handful of games. Even a fielder of fixed skill won't hit the same average every season — luck jiggles it. So when a new player scores a touch higher than your current star, you can't just swap them: the higher number might be a lucky streak. We measure how much luck can jiggle a single score — that's the standard error, biggest when the player is a coin-flip (around 50/50) and smaller the more games we watch. But we're comparing two jiggling numbers, and the gap between two jiggling numbers jiggles about 1.4 times more than either alone — so the cushion has to be a bit bigger than the naive guess. We insist the newcomer beat the star by that cushion . Since we never know a player's true rate, we plug in their observed average (or, to be safe, assume the noisiest 50/50 case, or just reshuffle the games many times and watch the spread). We also make sure we have enough games — at least ten wins and ten losses — before trusting the bell-curve maths at all, and we score both players on the exact same games so a paired comparison is possible. Clear the cushion and it's almost surely real skill, so we promote automatically; fall short and we keep the current star. That cushioned, automatic swap is the promotion gate at the heart of an ML CI/CD pipeline.


Active recall

Question
Answer
What is the difference between and ?
is the model's true, unknown correct-rate; is the measured score on one held-out set, which wobbles around .
Why does appear in the standard error?
It is the spread of a single correct/wrong "coin flip"; maximal at , zero at .
Why is the noise of the gap bigger than the noise of one score?
Variances of the two independent scores add, so .
What CLT condition must hold before using the bell-curve trick?
Both and (enough correct and enough wrong examples).
How do you fill in the unknown inside in practice?
Plug in the observed score , or use the worst case , or bootstrap the test set.
What does the "2" in approximate, and what are the exact values?
It's a rule of thumb; for a 95% two-sided test, for a 95% one-sided test.
Which exact test should you use when both models share the same test set?
A paired test — McNemar's test — on the examples where the two models disagree.
Why must both models use the same held-out set?
Otherwise the gap mixes model-skill difference with dataset difference, and a tighter paired test becomes impossible.

Connections

  • CI - CD pipelines for ML — the parent pipeline whose promotion gate this page derives.
  • Statistical Significance — the source of the -values and the exact/binomial tests.
  • A-B Testing & Canary Deployment — what to do for a barely promoting model.
  • Model Registry — stores each model with its eval-dataset version so comparisons stay fair.
  • Model Monitoring — watches live scores and feeds drift back to retrain triggers.