Concepts / PAC Learning

PAC Learning

Agnostic learning is needed when that perfect agreement cannot be assumed.

  • 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…

When Perfect Labels Fail

A traditional learning model often assumes that the features of every input determine one correct label with complete certainty. Under this assumption, there is a target labeling function, and some hypothesis in the class H agrees perfectly with that function. This is the realizability assumption. It makes learning conceptually clean: the learner searches for a hypothesis that makes no errors on the underlying labeling rule. Practical data, however, may not satisfy this assumption. Measured features may fail to capture everything that influences a label, so the same feature description can be associated with different labels. Agnostic PAC learning removes the requirement that one hypothesis represent the data perfectly.

Realizable datah in H agrees perfectlyTarget labelingfunctionone correct labelAgnostic datano perfect h in HOptimal hypothesisbest performance in Hperfect agreementclose to best in H
What changes when a perfectly correct hypothesis exists in H versus when every hypothesis makes some errors?

A Joint View of Data and Labels

Agnostic PAC learning describes data generation with a joint data-labels distribution over X × Y. Here, X represents the domain of possible feature descriptions and Y represents the possible labels. A joint distribution assigns likelihood to combinations of a domain point and a label. It therefore describes the two parts together: which point appears and which label accompanies that point.

Worked example

Papaya features and taste labels

Separate the questions answered by a distribution over papaya feature descriptions and taste labels.

  1. 1
    Start with a feature description

    Treat a papaya's measured features as a domain point x in X.

  2. 2
    Pair the point with a label

    A joint outcome is a pair consisting of that feature description and a taste label. The distribution describes how likely that pair is.

  3. 3
    Allow repeated feature descriptions

    The same feature description can occur with different labels in an agnostic model. The data-labels distribution records the probabilities of the different pairs rather than requiring one label to be correct with complete certainty.

  4. 4
    Separate occurrence from labeling

    The probability that the feature description appears is a marginal question. The probability of each taste label after that feature description is known is a conditional question.

Result

The joint distribution gives one model for both which feature descriptions occur and how labels are associated with them.

Feature point xsame domain description(x, y1)joint outcomey1conditional possibility(x, y2)joint outcomey2conditional possibilitypaired withpaired withcontainscontains
How can the same domain point x appear with different labels, and how are those possibilities represented in the joint distribution?

The diagram does not say that a single observation simultaneously has two labels. It shows that the same domain description can participate in different possible domain-label outcomes under the data-generating distribution. This is precisely what the realizability assumption rules out when it requires one correct label for each input description.

Marginal and Conditional Questions

ViewQuestion it answersWhat it describes
Marginal distributionWhich domain points are likely to appear?The distribution over domain points after labels are not the focus
Conditional probabilityGiven a particular domain point, how likely is each label?The label possibilities associated with that point
Joint distributionHow likely is a domain point-label pair?The data point and its label together

The marginal and conditional views answer different questions, while the joint distribution describes them together.

Marginaldistributiondomain pointsWhich x occurslikelihood of pointsJoint distributionx and y togetherConditionalprobabilitylabels given xWhich y given xlabel likelihoodsdescribesdescribespart ofpart of
What does the marginal distribution tell us about which points occur, and what does the conditional probability tell us about labels given a point?

Suppose the domain point is a papaya feature description. The marginal distribution asks how likely that feature description is to appear at all. It does not, by itself, answer which taste label accompanies the point. The conditional probability asks the second question: once the feature description is fixed, how likely is each label? Keeping these questions separate prevents a common misunderstanding. A point can be common or rare independently of whether its labels are concentrated or varied.

ERM and the Agnostic Goal

In agnostic PAC learning, the learner does not assume that the data can be represented perfectly by a hypothesis in H. The target therefore changes. Instead of requiring zero error, the learner seeks a hypothesis whose performance is close to that of the optimal hypothesis in H. This comparison is important: the learner is judged against the best available member of the chosen hypothesis class, not against a perfect hypothesis that may not exist.

Labeled sampleobserved dataEmpirical risksone value per h in HERMminimize empirical riskChosen hypothesislearner outputmeasurecompareselect
How does ERM move from a labeled sample to the hypothesis with the smallest empirical risk, and how does that produce a learner?
Worked example

Why ERM needs a theorem

Explain why selecting the hypothesis with the smallest empirical risk is not, by itself, enough to establish agnostic PAC learning.

  1. 1
    Observe the sample

    The learner receives a finite labeled sample from the joint data-labels distribution.

  2. 2
    Compute empirical risk

    ERM evaluates how each hypothesis performs on the observed sample and chooses a hypothesis with the smallest empirical risk.

  3. 3
    Connect sample performance to distribution performance

    The desired agnostic guarantee concerns true risk, not only performance on the observed sample. A theorem is needed to relate empirical risk to true risk.

  4. 4
    Compare with the class optimum

    Once the empirical and true risks are controlled together, the ERM output can be shown to perform close to the optimal hypothesis in H.

Result

ERM supplies the selection procedure; the risk-comparison argument supplies the learning guarantee.

Uniform Risk Control

Theorem 26.5 provides a uniform risk comparison for every hypothesis in the class. Its role is to control the difference between true risk and empirical risk, not merely for the hypothesis eventually selected by ERM, but for all hypotheses in H at once. This uniform statement is what allows the proof to analyze the data-dependent choice made by ERM. Without such a connection, a hypothesis could look best on the observed sample without the analysis establishing that it is close to the best choice under the underlying distribution.

Per-hypothesisboundsrisk deviationsFailure eventsone for each hUnion boundcombine probabilitiesUniform riskcomparisonall h in Hdefinecombinecontrol total failure
How do per-hypothesis deviation bounds combine through the union bound to ensure that empirical risks are close to true risks for all hypotheses at once?

The proof considers the possibility that a hypothesis has a substantial difference between its true risk and empirical risk. Theorem 26.5 supplies the relevant comparison for each hypothesis. The union bound then controls the probability that any of the relevant failure events occurs. The result is a statement that the comparison holds simultaneously across the hypothesis class, with a controlled probability of failure.

  • Common mistake

    Treating the theorem as a guarantee only for the ERM output.

    What it looks like

    The learner chooses a hypothesis after inspecting the sample, and the proof analyzes only that chosen hypothesis.

    Why it fails

    The chosen hypothesis depends on the sample. A guarantee stated uniformly for every hypothesis is what allows the proof to cover the data-dependent ERM choice.

    Do this instead

    Understand Theorem 26.5 as a simultaneous comparison across H before focusing on the hypothesis selected by ERM.

  • Common mistake

    Assuming the union bound makes every individual failure event impossible.

    What it looks like

    The proof combines failure events and concludes that each event has probability zero.

    Why it fails

    The union bound controls the probability of the combined event; it does not assert that every component event is impossible.

    Do this instead

    Use it to bound the probability that at least one relevant comparison fails.

  • Common mistake

    Confusing empirical risk with true risk.

    What it looks like

    A hypothesis has the smallest observed-sample risk, so it is declared optimal for the distribution.

    Why it fails

    Empirical risk is based on the sample, while the agnostic objective concerns performance under the data-generating distribution.

    Do this instead

    Use the uniform risk comparison to connect the two quantities.

Why Sample Size Matters

An upper-bound proof for agnostic PAC learnability establishes that there is a sufficient sample complexity for achieving the desired comparison with the optimal hypothesis in H. The sample-size condition is needed because the proof must make the final error small enough, typically below a chosen epsilon. The source material does not provide the literal algebraic expression for that sample complexity. The justified structural conclusion is that the proof first obtains a uniform risk bound, combines the relevant failure events with the union bound, and then imposes the sufficient condition from Lemma A.2 so the final error is below epsilon.

Small samplecondition not establishedRisk comparisonnot controlled enoughSufficient sampleLemma A.2 conditionPAC guaranteefinal error below epsilonmay leavesatisfies condition
How does increasing the sample size reduce estimation uncertainty enough to guarantee the desired PAC bound?
Before

Uniform risk bound established Union bound applied Sufficient sample-size condition not imposed

The proof has intermediate controls but no final sufficient condition.

After

Uniform risk bound established Union bound applied Lemma A.2 condition imposed Final error below epsilon

The proof reaches the desired agnostic PAC conclusion.

Practice: Trace the Proof

What do you think happens?

A learner uses ERM and selects the hypothesis with the smallest empirical risk. What additional argument is needed before calling this an agnostic PAC learner?

  • A claim that the selected hypothesis is perfectly correct

  • A comparison connecting empirical risk with true risk for the hypotheses under consideration

  • A claim that every domain point has only one possible label

  • A replacement of the joint distribution by a target labeling function

Reveal answer
Answer:

A comparison connecting empirical risk with true risk for the hypotheses under consideration

ERM minimizes empirical risk, but agnostic learning evaluates performance relative to the data-generating distribution. Theorem 26.5 supplies a uniform risk comparison, and the union bound controls the combined probability of failure.

EASY

A feature description x can be associated with labels y1 and y2 under a data-labels distribution. Identify which question belongs to the marginal distribution and which belongs to the conditional probability: how often x appears, and how likely y1 is once x is given.

Hints
  • The marginal view focuses on domain points.
  • The conditional view focuses on labels after a particular point is fixed.
MEDIUM

Put these proof moves in order: impose a sufficient sample-size condition, apply ERM to empirical risks, obtain a uniform true-versus-empirical risk comparison, and use the union bound to control the combined failure probability.

Hints
  • ERM is the learner's selection procedure.
  • The union bound combines failure events.
  • The sufficient condition is used for the final error target.

Key Takeaways

  1. 1
    Realizability requires some hypothesis in H to agree perfectly with a target labeling function, an assumption that may fail when measured features do not completely determine labels.
  2. 2
    Agnostic PAC learning uses a joint distribution over domain points and labels, allowing the same domain point to be associated with different possible labels.
  3. 3
    The marginal distribution describes which domain points occur, while the conditional probability describes labels given a particular point.
  4. 4
    ERM selects a hypothesis with the smallest empirical risk, but Theorem 26.5 is needed to connect empirical risk with true risk uniformly across H.
  5. 5
    The union bound controls combined failure events, and a sufficient sample-size condition ensures that the final error is below epsilon.

At a glance

  • Realizability demands perfect agreement between a hypothesis in H and a target labeling function; agnostic learning does not make that demand.
  • A joint data-labels distribution describes domain points and labels together and can assign different label possibilities to the same domain point.
  • The marginal distribution concerns which points occur, while conditional probabilities concern labels given a point.
  • ERM provides the selection rule, while Theorem 26.5, the union bound, and a sufficient sample-size condition provide the agnostic PAC guarantee.

Related concepts

More concepts starting with P