Using Hoeffding's inequality, how large must a test set be so that the measured error of a fixed classifier is within 0.02 of its true error with probability at least 95%?

Learning theory, Concentration inequalities
Level L2 Elementary. Length Short. Nature Mat Mathematical.

What's being asked

Whether you can apply Hoeffding's inequality to 0-1 losses and solve for m.

Key idea

Let L be the true error and L^ the error measured on m test points. For i.i.d. losses in [0,1], Pr⁡[∣L^−L∣>ϵ]≤2e−2mϵ2. Setting the right side to δ gives m≥ln⁡(2/δ)2ϵ2.

Steps

  1. Note that each test loss 1[h(xi)≠yi] lies in [0,1], has mean L, and the losses are i.i.d. because the classifier was fixed before the test set was drawn.
  2. Set 2e−2mϵ2≤δ and solve: m≥ln⁡(2/δ)/(2ϵ2).
  3. Plug in ϵ=0.02, δ=0.05: m≥ln⁡40/(2×0.0004)=3.689/0.0008≈4611.1, so m=4612.
  4. Remark: halving ϵ quadruples m. If you evaluate k models on the same test set and report the best, a union bound replaces ln⁡(2/δ) with ln⁡(2k/δ).

Common mistakes

How long your answer should be

Three lines of algebra and one number.

Last checked on 4 December 2026.

Read this

Previous in Learning theory: In online prediction with expert advice, what is regret, and what does it mean for an algorithm to have sublinear regret?
Next in Learning theory: What is the VC dimension of the class of closed intervals ha,b(x)=1[a≤x≤b] on the real line, and why?