Two classifiers A and B are evaluated on the same 1,000 test examples. A is right and B wrong on 30 examples; B is right and A wrong on 15. Is A significantly better at the 5% level, and what does the p-value mean here?

Probability and statistics, Hypothesis testing
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can choose a paired test for classifiers scored on the same test set, compute it, and interpret a p-value correctly.

Key idea

Only the examples where the models disagree tell you which is better. Under the null hypothesis H0 (equal error rates), each disagreement is equally likely to favour A or B. McNemar's statistic χ2=(∣b−c∣−1)2b+c then approximately follows a chi-squared distribution with 1 degree of freedom (χ12).

Steps

  1. Build the 2×2 table of (A right or wrong) against (B right or wrong). The two disagreement counts are b=30 (A right, B wrong) and c=15 (B right, A wrong). Ignore the examples where they agree.
  2. State H0: a disagreement is equally likely to go either way, so b∼Binomial(b+c,12).
  3. Compute: χ2=(∣30−15∣−1)245=19645≈4.36. The 5% critical value of χ12 is 3.84, and 4.36>3.84, so reject H0; p≈0.037. The “−1” is a continuity correction for using a smooth distribution on counts. Without it, 225/45=5.0 and p≈0.025. The exact two-sided binomial test gives p≈0.036.
  4. Interpret the p-value. It is the probability, if H0 were true, of seeing a split of disagreements at least this lopsided. It is not the probability that H0 is true, nor the probability that A is better.
  5. Explain why the test must be paired. Both accuracies come from the same examples, so they are correlated, and a test that treats them as independent is wrong. When comparing models across CV folds, the usual paired t-test underestimates the variance because the training sets overlap; use the 5×2 cv test or the corrected resampled t-test. If you test many models, correct for multiple comparisons.

Common mistakes

How long your answer should be

3–4 minutes: the table, the one-line statistic, then a sentence interpreting the p-value.

Last checked on 4 December 2026.

Read this

Previous in Probability and statistics: You can draw samples from Uniform(0,1), and you have Φ−1, the inverse CDF of the standard normal N(0,1). How do you generate samples from a 2D normal distribution N(μ,Σ), and how do you show that they have the right mean and covariance?
Next in Probability and statistics: Counts x1,…,xn are independent Poisson(λ) samples. Derive the MLE of λ. For the counts 2,0,3,1,4, what is λ^ and the probability that the next count is zero?