Hypotheses in ML

What are H0 and H1 hypothesis examples?

H0 is the null hypothesis, a default claim of no effect, and H1 is the alternative. Worked examples cover comparing two models, a website test and a sensor.

On this page
  1. The short answer
  2. Example 1: comparing two classifiers
  3. Example 2: a website test
  4. Example 3: a factory temperature sensor
  5. One-sided and two-sided alternatives
  6. Reading the result
  7. Two kinds of error
  8. Common mistakes

The short answer

H0, the null hypothesis, is the default claim: there is no effect, no difference, or no relationship. H1, the alternative hypothesis, is the claim the test looks for evidence to support, such as a difference or an improvement. The examples below show both forms.

Example 1: comparing two classifiers

Suppose you have a current classifier and a new one, and both are scored on the same held-out test set.

  • H0: the two classifiers have the same error rate.
  • H1: their error rates differ.

If you only care whether the new classifier is better, you can use a one-sided H1 instead: the new classifier has a lower error rate. When two classifiers are scored on the same examples, a paired test such as McNemar’s test is one common choice, because it focuses on the examples where exactly one of the two models is right.

Held-out evaluation, where the test set is kept apart from training, is what supplies the data for this comparison.

Example 2: a website test

A team changes the layout of a recommendation panel and wants to know whether it changes how often visitors click.

  • H0: the new layout does not change the click-through rate.
  • H1: the new layout changes the click-through rate.

Visitors are randomly shown either the old or the new layout, and the test compares the two click rates. If the team expected only an increase, the H1 would be one-sided: the new layout increases the click-through rate.

Example 3: a factory temperature sensor

An engineer recalibrates a temperature sensor on a production line to reduce its average error.

  • H0: the recalibration does not change the average error.
  • H1: the recalibration reduces the average error.

Here H1 is one-sided, because the goal is a reduction in error.

One-sided and two-sided alternatives

A two-sided H1 says the value differs in either direction. A one-sided H1 says it is greater than, or less than, the value in H0. Choose the form before looking at the data. Picking the direction after seeing which way the numbers moved makes false positives more likely.

Reading the result

The test produces a test statistic and a p-value. The p-value is the probability of a result at least as extreme as the observed one, assuming H0 is true. It is not the probability that H0 is true.

If the p-value falls below a threshold chosen in advance, often 0.05 by convention, H0 is rejected. If not, the test fails to reject H0. That means the data did not give enough evidence against it. It does not prove H0 is true.

Two kinds of error

  • A type I error rejects H0 when it is actually true. This is a false alarm.
  • A type II error fails to reject H0 when it is false. This is a missed effect.

The chosen threshold controls how often type I errors occur. Larger samples generally make it easier to detect a real effect, which lowers the chance of a type II error.

Common mistakes

  • Writing H1 after seeing the data.
  • Reading “not significant” as “no effect.”
  • Treating the p-value as the probability that H0 is true.
  • Mixing up the machine learning meaning of hypothesis, a candidate function, with the statistical meaning, a claim under test.

The complete guide to hypotheses in ml

Types of Hypothesis in Machine Learning
Read the guide

Keep exploring

Guides from other topics

All topics →