In shadow mode, the new model scores every request alongside the current champion, but only the champion's prediction is served. You collect real production data to compare — without risking user experience. When the challenger wins on key metrics, you promote it.
Champion at 90% accuracy, challenger at 91%, both scoring the same labelled requests. McNemar’s test looks only at the cases where they disagree. After 2,000 requests the p-value is 0.65 — no evidence either way. After 20,000 it is 0.0009. Shadow mode is safe, but a one-point improvement needs a lot of traffic to show.
- Shadow mode only sees the champion’s world: if the challenger’s decisions would change user behaviour, the shadow comparison cannot see it.
- Comparing on the requests that happen to get labels quickly can bias the result.
- A shadow model doubles serving cost while it runs; set an end date.
from scipy.stats import binomtest
rng = np.random.default_rng(3)
def shadow(n, p_champ=0.90, p_chal=0.91): # both models score the same n labelled requests
champ = rng.random(n) < p_champ
chal = np.where(rng.random(n) < 0.5, champ, rng.random(n) < p_chal) # they agree half the time by construction
only_chal, only_champ = (chal & ~champ).sum(), (champ & ~chal).sum()
return binomtest(only_chal, only_chal + only_champ).pvalue # McNemar's exact test
p_2k, p_20k = shadow(2_000), shadow(20_000)Assumes import numpy as np and import pandas as pd. Each snippet carries its own example numbers; the comments say which are made up or simulated.
- T. G. Dietterich, “Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms”, Neural Computation 10(7), 1998 — McNemar’s test
- Trustworthy Online Controlled Experiments, R. Kohavi, D. Tang & Y. Xu, Cambridge University Press, 2020
- Designing Machine Learning Systems, C. Huyen, O’Reilly, 2022
Last reviewed October 2026 · How this site checks its content · Report a mistake
1. What does shadow mode test?
Show answer
C. Shadow predictions are logged, never served, so any feedback loop through user behaviour stays invisible until an A/B test.
2. On 2,000 shadowed requests the challenger is right 91% of the time, the champion 90%. Promote it?
Show answer
A. The standard error of the difference is about one point here. Paired comparisons (same requests) help, but the sample is still small.
3. What does shadow scoring cost?
Show answer
B. Run the challenger asynchronously, off the request path, and sample traffic if compute is tight.