Concepts / Hypothesis Class

Hypothesis Class

A hypothesis class H is a set of functions from X to Y.

  • Programming
Interactive lab

Try it: Empirical Risk Minimization

How ERM picks the hypothesis in a finite class H with the smallest empirical risk on a random sample , how far its true risk can be from , how often ERM misses ε over many samples compared with the finite-class sample-complexity bounds, and how a richer class trades approximation error for estimation error until memorising the sample overfits.

How it works

  1. D is known: x is uniform over n points in [0, 1] and its label is a target rule f (a threshold or an interval), flipped with probability η; so every can be computed exactly.
  2. Draw : independent labelled examples from a seeded random stream.
  3. For every h in H (thresholds or intervals on a grid, listed in order), count its mistakes on S to get , and compute its true risk from . For the class of all functions, ERM simply memorises S: the majority label at each seen point, 0 elsewhere.
  4. ERM returns , the first hypothesis with the smallest . Compare with , and split into plus .
  5. Repeat with R fresh samples and count how often . The finite-class bound says (realizable, ) or (agnostic, ) keeps that frequency at most δ.
  6. Run the same samples through richer and richer classes: falls, the average rises, and memorising (all functions) reaches small with a large .

Default run (16 steps): D: x uniform over 20 points in [0, 1], label f(x) = 1[x >= 0.4] flipped with probability η = 0.1. H = thresholds on the grid i/10, |H| = 11. The learner never sees D; it gets S ~ Dm with m = 20. … Richer classes on the same 200 samples: ε_app falls from 0.42 (thresholds, k = 1) to 0.1 (all functions), while the average ε_est rises to 0.2282 for all functions (average LS 0.0617). Lowest average LD(hS): thresholds, k = 5 (0.1136).

Simplified: A toy domain of 8-40 equally likely points on a line, a target that is a threshold or an interval, and symmetric label noise, so is an exact finite sum rather than an integral over a continuous distribution. Hypotheses are thresholds or intervals with endpoints on a grid i/k, or all functions on the n points. ERM ties are broken towards the first hypothesis in listing order (for all functions: towards label 0), where the textbook allows any minimiser. Failure frequencies come from at most 400 seeded samples, so they estimate the probability rather than compute it; the bounds use the natural logarithm.

Educational simulation

Loading the simulation…

From Candidates to One Predictor

A learner does not always choose from every possible predictor. Instead, it may be restricted to a hypothesis class H, a set of functions from X to Y. Each function is a candidate rule for mapping inputs to predictions. Learning then becomes a controlled selection problem: examine the candidates, measure their performance on the training sample, and choose one.

This restriction matters because a finite class contains a finite number of candidates. A class can still represent a broad modeling idea while being finite. For example, predictors implementable by a C++ program using at most 10^9 bits of code form one example described in the source. Axis-aligned rectangles also become a finite class when their real-valued parameters are represented using a 64-bit floating-point representation.

Hhypothesis classh1X to Yh2X to Yh3X to Ycontainscontainscontains
How does a hypothesis class organize possible mappings from inputs to predictions?

Compressing Training Information

A compression scheme of size k describes how to reconstruct a hypothesis using only k selected labeled examples from the full training set. It uses two functions. Function A selects k indices from the complete training set. Function B receives the corresponding selected examples and produces a reconstructed hypothesis h' in H.

The key point is that A does not directly return the final hypothesis. A identifies which training examples are retained. B then uses those retained examples to construct a hypothesis in the class. The rest of the training set is not used as input to B for the reconstruction step.

Training set Slabeled examplesAselect k indicesSelected examplesk labeled examplesBreconstructh'member of Hinputkeepsinputproduces
How does function A select k labeled examples, and how does function B use only those examples to reconstruct a hypothesis?
Worked example

Tracing a Size-2 Scheme

Consider a generated training set with several labeled examples and a compression scheme of size 2.

  1. 1
    Selection

    Function A examines the full training set and selects two example indices.

  2. 2
    Retention

    The two indexed examples, including their labels, become the compressed representation of the training information.

  3. 3
    Reconstruction

    Function B receives those two selected examples and produces a hypothesis h' that belongs to H.

  4. 4
    Interpretation

    The scheme has compressed the information used for reconstruction to two labeled examples; it has not necessarily compressed the original training set itself into two examples for every purpose.

Result

A performs selection, while B performs reconstruction. The size is 2 because two labeled examples are selected.

Checking the Original Sample

Reconstruction is not complete merely because B returns a hypothesis in H. The reconstructed hypothesis must also have zero loss on the original training set. The check therefore compares h' with every example in the full training set, not only with the k examples selected by A.

This requirement separates two roles for the data. The selected examples are sufficient inputs for reconstruction, while the complete original sample is used to verify the zero-loss condition. A hypothesis that fits only the retained examples has not yet met the compression-scheme requirement.

Original set Sall examplesAll examples checkedfull sampleh'reconstructedZero losson Stest againstevaluaterequires
After reconstructing a hypothesis from selected examples, how is it checked against every example in the original training set to verify zero loss?

ERM Within a Finite Class

Empirical risk minimization, or ERM, examines how each candidate in a fixed collection performs on the training sample and chooses a hypothesis with minimum empirical risk. When the hypothesis class is finite, the learner is choosing from a finite number of candidates rather than from an unrestricted collection.

Restricting the learner to a finite class can limit overfitting because the learner has fewer candidate hypotheses available for selection. The class may still be large, so finiteness does not mean that the modeling idea is extremely narrow. The learning question remains whether the training-based choice will also perform well beyond the observed sample.

Finite Hcandidate hypothesesEvaluate candidatestraining sampleMinimum empiricalriskselect criterionhSERM resulth*zero empirical riskZero empirical riskfor hSinspectcomparechooseprovides benchmarkforces minimum to zero
How does ERM choose a hypothesis from a finite class, and what changes when realizability guarantees that some hypothesis has zero training error?
Worked example

Choosing Among Three Candidates

A generated finite class contains h1, h2, and h3. On one training sample, their empirical risks are 2, 0, and 1 respectively.

  1. 1
    Evaluate

    ERM considers the empirical risk of each candidate on the observed training sample.

  2. 2
    Compare

    The smallest listed empirical risk is 0, achieved by h2.

  3. 3
    Select

    ERM selects a hypothesis with minimum empirical risk, so h2 is an ERM result for this generated example.

  4. 4
    Limit of the conclusion

    The selection establishes performance on the training sample. It does not by itself establish low true risk.

Result

For this generated sample, ERM selects h2 because it has the smallest empirical risk.

Realizability and Its Consequence

Definition

Realizability places a hypothesis h* with zero true risk inside the hypothesis class H. The sample is drawn from the distribution and labeled by the target rule.

Because h* has zero true risk, it has empirical risk zero on the random training sample with probability 1. Thus ERM has an available candidate that makes no errors on the observed sample. Since ERM chooses a hypothesis with minimum empirical risk, every ERM result hS also has empirical risk zero in this setting.

Sample Fit Versus Distribution Performance

Empirical risk describes a hypothesis's performance on the observed training sample. True risk describes its performance under the data distribution. Therefore, zero empirical risk means that the hypothesis makes no errors on the available sample, while low true risk means that it performs well beyond that sample under the distribution.

Empirical riskobserved sampleZerono sample errorsTrue riskdata distributionLowfew distribution errorscan becan be
What is the difference between a hypothesis making no errors on the observed sample and making few errors on the full data distribution?
Worked example

Separating the Two Claims

A generated hypothesis makes no errors on the training sample.

  1. 1
    Sample-level statement

    The hypothesis has zero empirical risk because its predictions agree with the labels in the observed sample.

  2. 2
    Distribution-level question

    To discuss true risk, ask how the same hypothesis performs under the data distribution, including examples not present in the observed sample.

  3. 3
    Correct conclusion

    Zero empirical risk is an intermediate fact. It is not the same statement as low true risk.

Result

A perfect training fit does not, by itself, establish performance beyond the training sample.

Why Class Size Affects Data Needs

For a finite hypothesis class, the relationship between training-based selection and performance beyond the sample is tied to two conditions: the size of the class and the amount of training data. As the number of candidate hypotheses grows, the required amount of training data grows in relation to the size of the class.

The reason to track class size is that ERM is selecting among all available candidates. A finite class gives a controlled candidate set, but a larger finite set still gives the learner more candidates to compare. The sample-size requirement therefore cannot be discussed independently of how many hypotheses the class contains.

Hypothesis classfinite candidatesClass sizenumber of candidatesERM selectiontraining-based choiceTraining datarequired amount growsdeterminessets candidate scaleis tied to
Why must the training sample generally grow as the number of candidate hypotheses in the finite class grows?

Mistakes in Reasoning

  • Common mistake

    Treating A as the function that directly constructs the hypothesis.

    What it looks like

    A selects k indices from the full training set.

    Why it fails

    In the compression scheme, A performs selection, while B uses the selected labeled examples to produce h' in H.

    Do this instead

    Remember the division of labor: A selects; B reconstructs.

  • Common mistake

    Checking zero loss only on the selected examples.

    What it looks like

    A reconstructed hypothesis agrees with the k retained examples but disagrees with another example in the original sample.

    Why it fails

    The zero-loss requirement applies to the original training set, not just the compressed subset.

    Do this instead

    Evaluate the reconstructed hypothesis against every example in the original training set.

  • Common mistake

    Concluding that zero empirical risk means zero true risk.

    What it looks like

    An ERM result has no errors on the observed sample.

    Why it fails

    Empirical risk concerns the sample, whereas true risk concerns the data distribution.

    Do this instead

    State separately what was established on the sample and what remains to be established under the distribution.

  • Common mistake

    Assuming realizability guarantees that every hypothesis in H has zero empirical risk.

    What it looks like

    The class contains h* with zero true risk.

    Why it fails

    Realizability guarantees an available zero-risk target hypothesis, and therefore a zero-empirical-risk benchmark on the sample. It does not say that every candidate has zero risk.

    Do this instead

    Use h* to explain why the ERM minimum is zero under the stated setting.

  • Common mistake

    Ignoring the size of the hypothesis class when discussing training data.

    What it looks like

    Using the same sample-size reasoning for a class with few candidates and a much larger finite class.

    Why it fails

    The required amount of training data grows in relation to the size of the class.

    Do this instead

    Always identify both the candidate-class size and the available training amount.

Practice the Selection Logic

MEDIUM

A hypothesis class H is finite. It contains h1, h2, and h3. On a training sample, h1 has empirical risk 1, h2 has empirical risk 0, and h3 has empirical risk 2. Answer the following: Which hypothesis can ERM select? If the setting is realizable and h* is in H with zero true risk, what empirical-risk conclusion can you make about every ERM result? Finally, does either conclusion alone establish low true risk?

Hints
  • ERM chooses a hypothesis with minimum empirical risk.
  • Under realizability, h* has empirical risk zero on the random sample with probability 1.
  • Keep empirical risk tied to the observed sample and true risk tied to the data distribution.

What do you think happens?

If realizability gives ERM access to a hypothesis with zero empirical risk, what empirical risk must an ERM result have in this setting?

  • It must be greater than zero.

  • It can be any value because ERM ignores the training sample.

  • It has empirical risk zero.

  • It must have zero true risk.

Reveal answer
Answer:

It has empirical risk zero.

The realizable hypothesis h* provides a zero-empirical-risk candidate on the random sample with probability 1. ERM chooses a minimum-empirical-risk hypothesis, so every ERM result also has empirical risk zero. This does not by itself establish zero true risk.

Key Takeaways

  1. 1
    A hypothesis class H is a set of functions from X to Y.
  2. 2
    A size-k compression scheme uses A to select k training-example indices and B to reconstruct a hypothesis in H from the corresponding labeled examples.
  3. 3
    The reconstructed hypothesis must have zero loss on the entire original training set.
  4. 4
    ERM chooses a minimum-empirical-risk hypothesis from a finite class; under realizability, every ERM result has zero empirical risk on the random sample with probability 1.
  5. 5
    Zero empirical risk is a statement about the observed sample, not the same as low true risk under the data distribution.
  6. 6
    The required training amount grows in relation to the size of the finite hypothesis class.

At a glance

  • A hypothesis class is a set of candidate functions mapping X to Y.
  • Compression uses A for selecting k labeled examples and B for reconstructing a hypothesis that has zero loss on the original sample.
  • Finite-class ERM selects a candidate with minimum empirical risk.
  • Under realizability, ERM reaches zero empirical risk on the sample with probability 1, but this does not automatically imply low true risk.
  • The amount of training data needed is tied to the size of the hypothesis class.

Related concepts

More concepts starting with H