Tutorials › Statistical Learning (Graduate) › Realizable ERM and Zero-Error Sample Complexity

ERM Consistency and Rates · Tutorial 203 of 989

Realizable ERM and Zero-Error Sample Complexity

Learn how realizability and the class’s growth function yield a probability guarantee for the population error of any zero-training-error classifier.

Intermediate 10 min read

What You'll Learn

  • Define realizability and zero empirical classification error.
  • Prove a finite-class guarantee for zero-error empirical risk minimizers.
  • Define the growth function as a count of distinct sample labelings.
  • Derive a growth-function bound using an independent ghost sample and a random split.
  • Calculate sample-size guarantees and identify why zero training error alone is not enough.

Why Zero Training Error Needs a Guarantee

In binary classification, a learner may return a classifier that makes no mistakes on the observed sample. That is an exact statement about those observations, not automatically about future data. A classifier can agree with every sampled label while still disagreeing with the population label on a region the sample did not cover.

The realizable setting gives a useful starting point: the class contains at least one classifier whose population error is zero. Consequently, a classifier minimizing empirical error can achieve zero training error. The question is then how many observations make it unlikely that any zero-training-error classifier has population error greater than a chosen tolerance.

Definition: Let \((X,Y)\) have a distribution \(P\), where \(Y\in\{0,1\}\), and let \(\mathcal H\) be a class of measurable classifiers \(h:\mathcal X\to\{0,1\}\). The population risk of \(h\) is \(R(h)=P(h(X)\ne Y)\). For an iid sample \(S=((X_1,Y_1),\ldots,(X_n,Y_n))\), its empirical risk is \(\hat R_S(h)=n^{-1}\sum_{i=1}^n \mathbf 1\{h(X_i)\ne Y_i\}\). The problem is realizable when some \(h^*\in\mathcal H\) satisfies \(R(h^*)=0\). A classifier has zero empirical error when \(\hat R_S(h)=0\).

In the realizable case, \(\hat R_S(h^*)=0\) with probability one. Thus the minimum empirical risk over \(\mathcal H\) is zero, and every exact empirical risk minimizer has zero empirical error. A zero-error guarantee concerns the risk of such a fit, not whether the fitted classifier is the unique classifier with zero risk.

A Baseline: Finite Classes

For a finite class, a direct union bound gives a simple guarantee. Fix a classifier \(h\) with \(R(h)>\varepsilon\). Its probability of making no mistakes on \(n\) independent observations is \((1-R(h))^n\), which is at most \(\exp(-n\varepsilon)\). Taking a union bound over the class controls the chance that even one high-risk classifier fits the sample perfectly.

Theorem: Suppose \(\mathcal H\) is finite, the observations are iid, and the problem is realizable. For any \(0<\varepsilon<1\), with probability at least \(1-|\mathcal H|\exp(-n\varepsilon)\), every \(h\in\mathcal H\) with \(\hat R_S(h)=0\) satisfies \(R(h)\le\varepsilon\). In particular, any exact empirical risk minimizer has risk at most \(\varepsilon\) on this event.

Proof. For a fixed \(h\), independence gives

$$ P(\hat R_S(h)=0)=(1-R(h))^n. $$

If \(R(h)>\varepsilon\), then

$$ P(\hat R_S(h)=0) =(1-R(h))^n \le \exp(-nR(h)) \le \exp(-n\varepsilon), $$

using \(1-u\le e^{-u}\) for \(u\ge0\). There are at most \(|\mathcal H|\) classifiers to consider. Therefore the probability that at least one classifier with risk greater than \(\varepsilon\) has zero empirical error is at most \(|\mathcal H|\exp(-n\varepsilon)\). Outside that event, all zero-error empirical fits have risk at most \(\varepsilon\). Realizability ensures that an exact empirical minimizer is one of those fits. \(\square\)

For a desired failure probability \(\delta\), it is sufficient that

$$ n\ge \frac{\log|\mathcal H|+\log(1/\delta)}{\varepsilon}. $$

When the class is infinite, its cardinality cannot provide this bound. But on any particular finite sample, classifiers that make identical predictions cannot be distinguished by their sample labels. The growth function measures how many different labelings the class can produce, and can be finite even for an infinite class.

Definition: For an input domain \(\mathcal X\), the growth function of a binary class \(\mathcal H\) at \(m\) points is \(\Pi_{\mathcal H}(m)=\max_{x_1,\ldots,x_m\in\mathcal X}|\{(h(x_1),\ldots,h(x_m)):h\in\mathcal H\}|\). It counts the largest number of distinct prediction vectors that \(\mathcal H\) can produce on any \(m\) inputs. Repeated inputs are allowed in the maximization.

A Growth-Function Bound

The following bound applies to finite or countable measurable classes. Countability ensures that the event of interest is measurable and that, whenever a high-risk zero-error fit exists, one can select the first such fit in a fixed enumeration. The proof compares the observed sample with an independent sample of the same size, then conditions on their pooled observations.

Theorem: Suppose \(\mathcal H\) is a finite or countable class of measurable binary classifiers, the observations are iid, and the problem is realizable. For \(0<\varepsilon<1\) and \(n\varepsilon\ge8\),
$$ P\bigl(\exists h\in\mathcal H:\hat R_S(h)=0\ \text{and}\ R(h)>\varepsilon\bigr) \le 2\Pi_{\mathcal H}(2n)\,2^{-n\varepsilon/2}. $$

Thus any exact empirical risk minimizer has risk at most \(\varepsilon\) with probability at least \(1-\delta\) whenever \(n\varepsilon\ge8\) and \(2\Pi_{\mathcal H}(2n)2^{-n\varepsilon/2}\le\delta\). The appearance of \(2n\) reflects the proof’s use of two samples.

Proof. Let \(S'\) be an independent sample of size \(n\), and let \(A\) denote the event that some classifier has zero empirical risk on \(S\) and population risk greater than \(\varepsilon\). On \(A\), select the first such classifier \(h\) from an enumeration of \(\mathcal H\). Conditional on \(S\), the number of errors \(h\) makes on \(S'\) has a binomial distribution with mean \(nR(h)>n\varepsilon\). The multiplicative Chernoff bound gives a probability at most \(\exp(-nR(h)/8)\) that this count is below half its mean. Since \(n\varepsilon\ge8\), that probability is at most \(e^{-1}<1/2\). In particular, with conditional probability at least \(1/2\), \(h\) makes at least \(n\varepsilon/2\) errors on \(S'\). Let \(B\) be the event that some classifier has zero errors on \(S\) and at least \(n\varepsilon/2\) errors on \(S'\). It follows that \(P(B)\ge P(A)/2\), so \(P(A)\le2P(B)\).

To bound \(P(B)\), pool the \(2n\) iid observations and regard the assignment of \(n\) of them to \(S\) as a uniformly random split. Conditional on the pooled observations, each classifier induces an error pattern: a vector indicating which of the \(2n\) observations it misclassifies. There are at most \(\Pi_{\mathcal H}(2n)\) such patterns, because the observed labels are fixed and each prediction vector determines one error pattern.

For \(B\) to occur for a given pattern, every error in it must be assigned to \(S'\), while \(S\) receives none of them. If the pattern contains \(m\) errors, this is impossible when \(m>n\). Otherwise its probability is

$$ \frac{n(n-1)\cdots(n-m+1)}{(2n)(2n-1)\cdots(2n-m+1)} \le 2^{-m}, $$

because each factor \((n-j)/(2n-j)\) is at most \(1/2\). Event \(B\) also requires \(m\ge n\varepsilon/2\), so this probability is at most \(2^{-n\varepsilon/2}\). A union bound over the at most \(\Pi_{\mathcal H}(2n)\) patterns gives \(P(B)\le\Pi_{\mathcal H}(2n)2^{-n\varepsilon/2}\). Combining this with \(P(A)\le2P(B)\) proves the claim. \(\square\)

Worked Examples

Worked Example: Zero Error Can Still Hide Population Error

Let \(X\) be uniform on \(\{a,b,c,d\}\), and let \(Y=0\) always. Consider the four classifiers \(h_0\equiv0\), \(h_1=\mathbf 1\{X=a\}\), \(h_2=\mathbf 1\{X=b\}\), and \(h_3=\mathbf 1\{X\in\{a,b\}\}\). The problem is realizable because \(R(h_0)=0\). The other risks are \(R(h_1)=R(h_2)=1/4\) and \(R(h_3)=1/2\).

Set \(\varepsilon=0.2\). All three nonzero-risk classifiers have risk greater than \(\varepsilon\). The classifier \(h_1\) fits the sample perfectly exactly when no observation has \(X=a\), an event of probability \((3/4)^n\). Similarly, \(h_2\) fits perfectly with probability \((3/4)^n\). Both fit perfectly when neither \(a\) nor \(b\) occurs, with probability \((1/2)^n\). Since \(h_3\)'s zero-error event is precisely that joint event, the probability that at least one bad classifier fits perfectly is

$$ 2(3/4)^n-(1/2)^n. $$

At \(n=10\), this is \(2(0.75)^{10}-(0.5)^{10}\approx0.11165\). So even though a perfect classifier is in the class, there is about an 11.17% chance that a classifier with risk greater than 0.2 also has zero sample error.

Worked Example: A Finite-Class Sample-Size Calculation

Suppose \(|\mathcal H|=5\), the problem is realizable, and the goal is to ensure that every zero-error empirical fit has risk at most \(\varepsilon=0.1\), with failure probability at most \(\delta=0.05\). The finite-class bound requires

$$ 5e^{-0.1n}\le0.05 \quad\Longleftrightarrow\quad e^{-0.1n}\le0.01 \quad\Longleftrightarrow\quad n\ge\frac{\log(100)}{0.1} \approx46.05. $$

Therefore \(n=47\) suffices. Indeed, \(5e^{-4.7}\approx0.0455<0.05\). Under the stated assumptions, with probability at least 95%, every classifier in the class that achieves zero training error has population risk at most 0.1.

Worked Example: Thresholds and the Growth Function

Consider classifiers on the real line of the form \(h_t(x)=\mathbf 1\{x\ge t\}\), with \(t\in\mathbb R\). On \(m\) distinct, ordered points, a threshold can change its predicted label only once. There are at most \(m+1\) possible prediction vectors: the split can occur before the first point, between successive points, or after the last point. Hence \(\Pi_{\mathcal H}(m)\le m+1\), including samples with repeated inputs.

For \(\varepsilon=0.1\), the growth-function theorem at \(n=300\) has \(n\varepsilon=30\ge8\), and its probability bound is

$$ 2\Pi_{\mathcal H}(600)2^{-15} \le 2(601)2^{-15} =\frac{1202}{32768} \approx0.03668<0.05. $$

Thus, whenever the threshold problem is realizable, any threshold with zero empirical error has population risk at most 0.1 with probability at least \(1-0.03668\), which is greater than 95%. This is a sufficient sample size, not a claim that 300 is the smallest one.

What the Guarantee Does—and Does Not—Say

The finite-class bound depends on the number of classifiers; the growth-function bound depends on the number of distinct labelings they can generate on a finite set of inputs. This distinction matters when \(\mathcal H\) is infinite: many classifiers may behave identically on the observed inputs, so the raw cardinality can be uninformative while the growth function still provides a bound.

The guarantee is probabilistic and distribution-free within the realizable setting: it holds for any distribution for which some classifier in \(\mathcal H\) has zero population risk. It does not say that a particular finite sample must contain every region where classifiers disagree, nor that a zero-training-error fit has exactly zero population risk. Instead, it bounds the probability of selecting—or even having available—a zero-error fit whose risk exceeds the chosen tolerance.

Common Mistake

  • Wrong reasoning: “The training error is zero, and the problem is realizable, so the fitted classifier has population error zero.” Realizability only guarantees that some member of the class has zero population risk. Other classifiers can also fit the observed sample perfectly while making errors elsewhere.
  • Correction: Control the probability that any high-risk classifier is consistent with the sample. The finite-class bound does this through \(|\mathcal H|\); the growth-function bound does it through \(\Pi_{\mathcal H}(2n)\). Both require an explicit sample-size calculation to obtain a stated risk tolerance and confidence level.
Key takeaway: In a realizable problem, empirical risk minimization produces zero training error, but population risk is controlled only probabilistically. A finite class gives a direct cardinality bound; a growth function extends the guarantee to classes whose number of distinct finite-sample labelings can be controlled.

Check Your Understanding

Answer each question using the definitions and guarantees in this tutorial.

  1. What does realizability assert, and why does it imply that the minimum empirical risk is zero?
  2. For a fixed classifier with population risk \(r\), what is the probability that it makes zero errors on an iid sample of size \(n\)?
  3. Why can a growth function give useful information about an infinite class when its cardinality cannot?
  4. In the ghost-sample proof, why does a classifier with risk greater than \(\varepsilon\) make at least \(n\varepsilon/2\) errors on the independent sample with probability at least one half when \(n\varepsilon\ge8\)?
  5. For thresholds on the real line, why is the number of prediction vectors on \(m\) ordered points at most \(m+1\)?
Clinical Biostats