KatInterview

Comparing Two Models on Shared Test Data

Statistics & ExperimentsModel answer
MediumModel answerStatistics & Experimentshypothesis-testingpaired-comparisonscontingency-tables

Last updated

Apply statistical tests to determine whether two classifiers differ significantly when evaluated on the same labeled dataset, covering hypothesis testing, exact methods, confidence intervals, and multiple comparisons.

Comparing Two Models on Shared Test Data

You built two classification models, A and B, and evaluated both on the identical set of 10,000 labeled examples. The results break down as follows:

B CorrectB Incorrect
A Correct8,740300
A Incorrect220740

Your task is to determine whether the two models have meaningfully different error rates.

Part 1: Statistical Test with Continuity Correction

Apply a standard paired-sample test for model accuracy. Compute the test statistic and two-sided p-value using continuity correction. Show all intermediate calculations: identify which cells matter, compute their difference and sum, and evaluate the test statistic.

Part 2: Exact Calculation

Recompute the p-value without the normal approximation, using an exact method based on the binomial distribution. Describe when you would choose the exact approach over the continuity-corrected version.

Part 3: Confidence Interval

Construct a 95% confidence interval for the difference in accuracy between A and B. Name your method and explain why you selected it over alternatives.

Part 4: Real-World Considerations

  1. State the key assumptions your test relies on. When might they be violated?
  2. Describe scenarios where the test would be inappropriate or misleading.
  3. You now want to compare model A against 10 different models on the same test set. How would you adjust your testing strategy to control for multiple comparisons?

Hints

Hint 1

Only the discordant pairs (where the models disagree) carry information about which is better; the concordant pairs contribute equally to both models.

Hint 2

The test statistic under the null hypothesis follows a known distribution; identify which one and why.

Hint 3

The paired setting means the two accuracies are not independent—this affects the standard error of their difference.

Hint 4

With many comparisons, the probability of a false positive across all tests grows; choose a correction method that controls this rate.