What is hypothesis testing?
Hypothesis testing is a procedure for deciding whether data give enough evidence to reject a default claim, called the null hypothesis H₀. You compute a test statistic from the data, find how likely a value at least that extreme would be if H₀ were true (the p-value), and reject H₀ if that probability falls below a threshold α chosen in advance.
In machine learning, hypothesis tests check whether a new model beats a baseline or just got lucky on the test set, using tools such as McNemar's test or a paired bootstrap. They also decide A/B tests of deployed models, detect drift between training and production data, and flag features whose link to the label could be chance.
Key ideas
- H₀ is the default claim of no effect, and a test asks whether the data are surprising under it.
- A test statistic measures how far the data sit from H₀, in units of standard error.
- The p-value is the probability, assuming H₀ is true, of data at least as extreme as what was observed.
- α is the false positive rate you accept, and it is fixed before looking at the data.
- Power is the probability of detecting an effect that is really there.
- The required sample size grows with the inverse square of the effect size.
Common questions
What is the multiple comparisons problem?
Each test at α = 0.05 has a 5% false positive rate, so running 20 independent tests on pure noise gives at least one "significant" result about 64% of the time. The Bonferroni correction tests each at α/m for m tests. The Benjamini-Hochberg procedure controls the false discovery rate instead, which keeps more power when there are many tests.
What is the difference between statistical and practical significance?
Statistical significance says an effect is unlikely to be zero. Practical significance says it is large enough to matter. With millions of samples, a 0.01% improvement can have a tiny p-value and still be worthless, so report effect sizes and confidence intervals along with p-values.
How do you test whether one ML model is better than another?
When both models are scored on the same test set, use a paired test. McNemar's test compares the counts of examples that only one of the two models gets right. A paired bootstrap resamples the test set many times and checks how often the accuracy gap changes sign. Dietterich (1998) also recommends the 5×2 cross-validation paired t-test.
Does failing to reject H₀ mean H₀ is true?
No. It means the data were not strong enough to rule H₀ out. With low power, a real effect is easy to miss, so a non-significant result from a small sample says very little. Equivalence tests are the right tool for showing that an effect is close to zero.
Related explainers
- Statistics Essentials — Mean, variance, standard deviation, and the Central Limit Theorem
- Probability & Distributions — Spam, densities, and the math of uncertainty
- Bayes' Theorem — Updating beliefs with evidence
- Model Evaluation & Metrics — Precision, recall, F1, ROC curves, and regression metrics
- Cross-Validation — K-fold, stratified, and leave-one-out evaluation
- Sampling & Monte Carlo — Random sampling, the law of large numbers, and Monte Carlo estimation
References
- Wasserstein & Lazar (2016), "The ASA Statement on p-Values: Context, Process, and Purpose", The American Statistician
- Dietterich (1998), "Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms", Neural Computation
- Benjamini & Hochberg (1995), "Controlling the False Discovery Rate: A Practical and Powerful Approach to Multiple Testing", JRSS Series B
- James, Witten, Hastie & Tibshirani, "An Introduction to Statistical Learning", 2nd edition, chapter 13: Multiple Testing
Last updated