A 20-row subgroup drops to 80% precision. Should you block release?
Question
Before releasing a new classifier, your eval report shows 92.0% overall precision (1,840 / 2,000). A small regional subgroup has only n = 20 flagged cases and shows 80.0% precision (16 / 20). One teammate says "block the launch immediately". Another says "ignore small slices and look at the overall 92%".
- Compute the Wilson 95% confidence interval for
16 / 20and compare it with160 / 200(also 80.0%) and overall1,840 / 2,000. - Why are both teammates falling into a trap?
- How do you evaluate and gate small subgroups reliably?
Show hints (3)
- "CHECK THE 95% CI"
With
z = 1.96, a proportion16 / 20has a Wilson interval spanning more than 30 percentage points. Does it almost reach92%? - "COMPARE N=20 VS N=200"
Now keep precision at
80%withn = 200(160 / 200). How much narrower does the 95% interval become, and does it still overlap92%? - "CHECK THE MASKING TRAP"
Suppose a 20-row slice (
1%of 2,000) really collapses to40%precision (8 / 20). How much does overall precision move from92.0%?
Show checked explanation
Do not auto-block or ignore it. For 16 / 20 (80.0%), the Wilson 95% CI is [58.4%, 91.9%] (33.5 points wide). It nearly reaches the 92.0% baseline and overlaps the overall 95% CI [90.7%, 93.1%] (P(X <= 16 | p = 0.92) = 0.071). By contrast, 160 / 200 gives [73.9%, 85.0%], clear proof of a gap. Report Wilson CIs, oversample small slices, aggregate longer windows, and inspect the four errors.
import math from statistics import NormalDist Z = NormalDist().inv_cdf(0.975) # 95% two-sided normal quantile (~1.96) def wilson_ci(k, n, z=Z): p = k / n denom = 1 + z * z / n center = (p + z * z / (2 * n)) / denom half = z * math.sqrt((p * (1 - p) + z * z / (4 * n)) / n) / denom return center - half, center + half slices = [("overall", 1840, 2000), ("small", 16, 20), ("larger", 160, 200), ("perfect", 20, 20)] for name, k, n in slices: lo, hi = wilson_ci(k, n) print(f"{name:7} {k:4d}/{n:<4d} ({k / n:5.1%}) " f"95% CI [{lo:.1%}, {hi:.1%}] width={(hi - lo) * 100:.1f}pp")
overall 1840/2000 (92.0%) 95% CI [90.7%, 93.1%] width=2.4pp small 16/20 (80.0%) 95% CI [58.4%, 91.9%] width=33.5pp larger 160/200 (80.0%) 95% CI [73.9%, 85.0%] width=11.0pp perfect 20/20 (100.0%) 95% CI [83.9%, 100.0%] width=16.1pp
Code, Wilson 95% intervals, and exact binomial checks run on CPython 3.12.10 (stdlib only) against the subgroup counts above; official SciPy and Python documentation links checked by the author. Checked by an editor other than the author.
Walkthrough
A point estimate without sample size hides how noisy a tiny slice is. Use the Wilson score interval for binomial rates (k / n), because the textbook Wald formula p +/- z * sqrt(p*(1-p)/n) under-covers small n and collapses to zero width at 20 / 20 ([100.0%, 100.0%] vs Wilson [83.9%, 100.0%]).
| Slice | Count | Point precision | Wilson 95% CI | CI width |
|---|---|---|---|---|
| Overall | 1,840 / 2,000 | 92.0% | [90.7%, 93.1%] | 2.4 pp |
| Small subgroup | 16 / 20 | 80.0% | [58.4%, 91.9%] | 33.5 pp |
| Larger subgroup | 160 / 200 | 80.0% | [73.9%, 85.0%] | 11.0 pp |
| Perfect tiny slice | 20 / 20 | 100.0% | [83.9%, 100.0%] | 16.1 pp |
1. Trap A: blocking blindly on n = 20 noise. With n = 20, a single case moves precision by 5 percentage points. Flipping just one error to a hit (17 / 20 = 85.0%) shifts the 95% CI to [64.0%, 94.8%]. Even if true precision is still 92.0%, seeing 16 or fewer hits in 20 trials happens 7.1% of the time by chance. At n = 200, the same 80.0% yields [73.9%, 85.0%] (p < 1e-7), clearly below the [90.7%, 93.1%] overall band.
2. Trap B: ignoring small subgroups. Suppose this 20-row slice (1% of traffic) really drops from 90% (18 / 20) to 40% (8 / 20). Overall precision barely budges from 92.0% (1,840 / 2,000) to 91.5% (1,830 / 2,000). Overall averages silently hide real harm on minority regions, languages, or high-value tiers.
3. How to gate small subgroups cleanly.
- Inspect the 4 errors immediately. On
n = 20, reading all four false positives takes five minutes and spots systematic bugs (like a broken currency parser) faster than any test. - Set a minimum
nbefore hard CI gating. Detecting a drop from92%to80%at 80% power (alpha = 0.05) needs at least53rows against a fixed benchmark (128per arm for two-sample comparison). - Grow signal deliberately. Oversample key slices with stratified evaluation, or aggregate over longer rolling windows. You can also use hierarchical (Bayesian) pooling to shrink noisy slices toward the global rate without hiding large drops.
Common mistakes
- Hard-gating releases on raw point estimates for 50 tiny slices. By multiple-testing chance alone, several
n = 20slices dip below 85% on every single release. - Using the Wald formula
p +/- 1.96 * SEon small or extreme proportions. It overflows100%or gives zero width on20 / 20; use Wilson or exact binomial intervals. - Dropping small slices from dashboards because they are noisy. A 1% slice collapsing to
40%moves overall precision by only0.5points (92.0%to91.5%). - Forgetting to check the actual error rows. Four errors on
n = 20are small enough to inspect by hand and catch deterministic feature bugs immediately.
Follow-up questions
- "You track 30 regions on every release. How do you stop false alarms without missing real regional regressions?" Require both statistical evidence and a meaningful drop. Apply Benjamini-Hochberg FDR control (or a stricter alpha) across slices above your minimum
n. For tiny slices, track a rolling multi-week window and alert when the upper CI bound falls below your floor. - "When does hierarchical (Bayesian) pooling help, and when can it mislead you?" Empirical-Bayes pooling shrinks noisy
n = 20estimates toward the global92%rate, cutting false alarms while lettingn = 200slices speak for themselves. It can under-report a genuinely broken tiny region early on, so always show raw countsk / nand Wilson CIs beside pooled rates.
What a strong answer covers
Computes Wilson 95% CIs for 16 / 20 ([58.4%, 91.9%]) vs 160 / 200 ([73.9%, 85.0%]), exposing both traps: gating on tiny-slice noise and masking real slice failures inside overall averages. Inspects the four errors, sets minimum n (~53), and uses stratified sampling, longer windows, or pooling.
Open in interactive practice deck →
proportion_ci (Wilson method) · Python statistics.NormalDist.