MLOps: Models in the Real World

Fair Race

Robo built a new game-recommending model, B. Is it really better than the old one, A? The only fair way to know: send real players to each and count how many click Play. But luck plays tricks, and stopping too early lets luck fool you.

Press Play and players start arriving. Each one is sent to A or B. Watch the two click rates, their wobbly "could be anywhere in here" bars, and the p-value line.

Players: 0

Dot = click rate so far. Bar = 95% confidence interval: the real rate is probably somewhere inside. Bars shrink as more players arrive.

p-value: "if A and B were really the same, how often would luck make a gap this big?" Below the red line (0.05) people call it a winner. Watch how it wiggles!

The peeking problem: 200 races where nobody is better

Each square is a whole A/A race (A and B are identical, so any "winner" is fake). Every race runs up to 1,000 players per group. Peeking checks the p-value every 25 players and stops at the first p < 0.05. Planned only checks once, at the end.

Peeking: stop at first p < 0.05

Fake winners: -

Planned: check once at the end

Fake winners: -

The promise of "p < 0.05" is: only about 5 races in 100 (10 of these 200) show a fake winner. That promise only holds if you look once.

Challenges

Catch a fake winner: in an A/A test, watch the p-value dip below 0.05 even though A and B are identical.
Find the sample size for a 2-point lift (10% → 12%), and plan the race with it.
Cry wolf: run 200 A/A races and see peeking find fake winners more than 10% of the time.
Beat fixed split with the bandit: in a race where A and B really differ, watch the bandit view until it has fewer missed clicks after 2,000 players.

What just happened?

How it works

  1. Each player flips a coin (weighted by the split slider) to see A or B.
  2. The player clicks Play with the model's secret true chance. We only see clicks, never the chance.
  3. Click rate = clicks ÷ players for each model, with a 95% interval around it.
  4. The z-test turns the gap between the rates into a p-value: big gap and lots of players = small p.
  5. The bandit keeps a belief about each model's rate, makes a lucky guess from each belief, and sends the player to the bigger guess.
For grown-ups: what's really going on

Users are Bernoulli trials with hidden rates pA, pB (8–14%, B differs by −2 to +4 points, or equals A in A/A mode). The two-proportion z-test uses the pooled estimate: z = (p̂B − p̂A) / √(p̂(1 − p̂)(1/nA + 1/nB)), two-sided p = 2(1 − Φ(|z|)). Intervals are 95% Wilson score intervals, which behave better than ±1.96·SE for small n and rates near 0.

  • Sample size per group for α = 0.05 (two-sided), power 1 − β = 0.8: n = (z1−α/2√(2p̄(1−p̄)) + z1−β√(p1(1−p1) + p2(1−p2)))² / (p2 − p1)². 10% → 12% needs 3,841 per group; halving the effect roughly quadruples n.
  • Optional stopping ("peeking"): with 40 looks the chance that a random walk of z ever crosses ±1.96 is far above 5% (about 25–30% here). Valid alternatives: fix the horizon; group-sequential designs with alpha-spending boundaries (Pocock, O'Brien–Fleming); or always-valid sequential tests (mSPRT, e-values) built to be checked continuously.
  • Under H₀ p-values are uniform on [0, 1], so a single fixed-horizon test has exactly α false positives; the 200-race grid estimates that rate with about ±3 points of noise.
  • Thompson sampling: Beta(1 + clicks, 1 + misses) posteriors; each user goes to the arm with the larger posterior draw. It minimises regret Σt (max(pA, pB) − parm(t)), but adaptive allocation biases the naive z-test and starves the losing arm of data, so bandits optimise reward rather than give a clean estimate.
  • Both strategies share common random numbers: each user has one uniform draw u and converts on arm k iff u < pk, so their regrets are directly comparable.

Further reading: Kohavi, Tang and Xu (2020), Trustworthy Online Controlled Experiments; Johari et al. (2017), Peeking at A/B Tests; Russo et al. (2018), A Tutorial on Thompson Sampling.