Measure agreement between a shadow model and production
Why it matters Shadow deployments are the standard safety check before swapping a production model.
Before promoting a model, run it in shadow and compare its predictions with production.
Write shadow_agreement(prod, shadow, tol=0.0). Both are lists of predictions (numbers or labels). For numbers, they agree if |a - b| <= tol. For non-numbers, they agree if equal. Return the fraction of agreeing pairs.
def shadow_agreement(prod, shadow, tol=0.0)Example
shadow_agreement([1, 2, 3], [1, 2, 4]) is 2/3.
Understand the idea
In shadow mode a new model receives the same live traffic as production, but its answers are only logged, not shown to users. Comparing the two tells you how often the new model would change outcomes before you promote it. Numeric predictions agree if they are within a tolerance; labels agree only if they are equal. Worked example: prod = [0.91, 0.40, 'spam', 'ham'], shadow = [0.90, 0.55, 'spam', 'spam'], tol = 0.05. Pair 1 differs by 0.01, within 0.05, agree. Pair 2 differs by 0.15, disagree. Pair 3 is equal labels, agree. Pair 4 differs, disagree. Agreement = 2 / 4 = 0.5. With tol = 0, exactly equal numbers must still count as agreeing, so use <= not <. Rule: for each pair, if both are numbers, agree when |a - b| <= tol; otherwise agree when a == b; return agreeing pairs / total pairs. Used in: safe model rollouts, checking that a distilled or quantised model matches the original, and canary comparisons in ML platforms.