A classifier gets 340 of 400 test examples right. Give an approximate 95% confidence interval for its true accuracy. How large must the test set be to estimate accuracy to within ±2 percentage points at 95% confidence, if you have no prior idea of the accuracy?

ML systems and evaluation, Evaluation statistics
Level L2 Elementary. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can attach uncertainty to a single test accuracy using the binomial standard error, and invert it to size a test set.

Key idea

The number of correct predictions is binomial, so the standard error (SE) of the sample accuracy p^ on n examples is p^(1−p^)/n, and an approximate 95% confidence interval is p^±1.96 SE.

Steps

  1. Compute the sample accuracy and standard error: p^=340/400=0.85, so SE=0.85×0.15/400=0.00031875≈0.0179.
  2. Construct the 95% interval: 0.85±1.96×0.0179≈0.85±0.035, giving [0.815, 0.885].
  3. Invert the formula for margin of error m=0.02: we need 1.96p(1−p)/n≤m, so n≥1.962 p(1−p)/m2.
  4. Use the worst-case prior p=0.5 (where p(1−p)=0.25 is largest): n≥3.8416×0.25/0.0004=2,401 examples.
  5. Compare with trusting p≈0.85: you would need only n≥3.8416×0.1275/0.0004=1,224.51, so at least 1,225 examples—roughly half as many.
  6. State the takeaway: small test sets yield wide intervals, so a 1-percentage-point accuracy gain on 400 examples sits well inside sampling noise.

Common mistakes

How long your answer should be

Half a page; 4 minutes.

Read this

Previous in ML systems and evaluation: A credit score model’s training score distribution across four equal-frequency bins is [0.25,0.25,0.25,0.25], while live production traffic shifts to [0.10,0.20,0.30,0.40]. What is the population stability index (PSI), how severe is the drift under standard thresholds, and why should rising PSI trigger investigation rather than automatic blind retraining?
Next in ML systems and evaluation: Two classifiers A and B are evaluated on the same 200 test examples. Both are right on 150, both are wrong on 15, only A is right on 25 and only B is right on 10. Test at the 5% level, using McNemar's statistic χ2=(b−c)2/(b+c) (where b and c count the examples on which only one of the two classifiers is right) and the 5% critical value 3.84, whether the difference in accuracy is real. Why not simply compare the two accuracies?