How Well Do We Learn?
In the previous chapters, we defined learning as the construction of a hypothesis from a finite sample. We also distinguish the error observed in the training data from the expected error in future examples. Now we face the quantitative question: when the observed error provides reliable information about the true error?
Consider a hypothesis and an i.i.d. sample.
For a limited loss, we calculated the empirical risk
but we want to know the expected risk
As is unknown, cannot be calculated directly. Generalization theory studies the difference
A small difference indicates that the sample estimates the performance of the hypothesis well. A large difference means that the result observed may be a misleading description of the population.
The first difficulty: the sample is random. If we repeat the collection, we will obtain other examples and other empirical risk. We need a probabilistic statement that limits the chance of a large deviation. Hoeffding inequality will fulfill this role for means of independent and limited variables.
The second difficulty: the hypothesis also depends on the sample. Hoeffding directly controls a hypothesis fixed before observing the data. An algorithm, however, examines the data and chooses
If we look among many hypotheses, some may seem good only by chance. This effect is similar to throwing many coins and selecting the one that presented the highest proportion of faces: the selection makes the extreme result less surprising.
The third difficulty: many classes are infinite. There are infinite straight, flat and combinations of real weights. We can’t just count all the elements of . We need to measure how many distinct behaviors the class can produce over a finite sample.
The Vapnik–Chervonenkis dimension, or VC dimension, measures this capacity in binary classification. It is the largest size of a set that can be shattered by the class: all its binary labels can be performed by some hypothesis.
For linear classifiers in the plane, the VC dimension is :
- there are three points that can receive any labels and still be separated by a straight line;
- no set of four points can perform, by straight lines, all possible labels.
The four vertices of a square with alternate labels form the known XOR pattern and show a labeling that a line does not separate. To conclude that the dimension is , however, we still need to argue that all four-point set fails in some labeling, not just display a particular set.
The script of the chapter. We will develop the analysis in steps:
- we will understand the defect of selecting hypotheses using the same sample in which we measured the error;
- We will apply Hoeffding’s inequality to a fixed hypothesis and then to finite classes;
- We will replace the cardinality of an infinite class with the number of labels it induces in finite samples;
- we will define VC dimension and obtain capacity-dependent generalization bounds.
A typical guarantee will have the form
The supreme requires that the approach be valid simultaneously for all hypotheses. This allows you to choose a hypothesis after observing the sample without losing the warranty.
3.0.1 Capacity, data and trust
The bounds will reveal three general dependencies:
- greater accuracy, that is, smaller , requires more examples;
- greater confidence, that is, smaller , requires more examples;
- a more expressive class requires more examples to control selection and overfit.
These relationships do not justify universal rules such as “ten examples per parameter”. The amount required depends on loss, effective capacity, distribution, noise and the type of guarantee. Theoretical bounds of worst case may be conservative, but their structure explains what factors make learning more difficult.
3.0.2 What bounds can and cannot do
A generalization bound does not automatically choose the best representation, does not correct incorrect labels and does not guarantee stability when distribution changes. It answers a conditional question: under certain hypotheses, what is the probability that empirical performance differs greatly from expected?
We must also distinguish:
- theoretical bound: valid for a family of situations, often conservative;
- experimental estimate: calculated in validation or test for a concrete model and set.
The theory explains why the procedure can generalize; the evaluation measures how a specific implementation behaved.
A change of perspective
The problem is not just finding a hypothesis with low training error. It is controlling how many opportunities the algorithm had to find an accidental adjustment and demonstrating that the low error contains information about new data.
3.0.3 Motivating example: multiple coins
Suppose honest coins, each launched times. For a coin fixed before the experiment, the frequency of faces tends to get close to . However, if we choose later the coin with less frequency of faces, the selected value will be more extreme as grows.
The selected currency plays the role of the hypothesis chosen by the algorithm. Each individual currency has good concentration, but controlling the selection requires considering all candidates. For a finite set, we will do this with the union bound; for infinite classes, we will use combinatorial capacity.
3.0.4 Preparing questions
- Differentiate empirical risk and expected risk.
- Why cannot a guarantee for a fixed hypothesis be applied directly to ?
- How does increasing the amount of chances affect the chance to find an accidental fit?
- What does it mean to break a set?
- Why does the four-point XOR pattern alone not complete the proof that flat lines have VC dimension equal to ?
- Explain why there is no universal rule of examples per parameter.
3.1 Defect
Given a hypothesis, we can calculate your empirical risk in the sample,
But not your exact expected risk,
because the distribution is unknown. We will call generalization gap — or, following the historical terminology of this text, defect — the difference
Identity
shows the two ingredients of a good result: small training error and controlled gap.
3.1.1 Signed gap and absolute gap
is a signed quantity:
- : training underestimated the true error;
- : training overestimated the true error;
- : the sample estimated the risk well.
For a guarantee that doesn’t depend on the steering, we use
So,
We do not try to “minimize the gap” directly, because it involves , which we do not know. We try to demonstrate that it is small with high probability.
3.1.2 Binary classification
For and zero-one loss,
e
The first is the frequency of errors in examples; the second is the probability of error in a new example.
If and a bound guarantees
So…
The bound does not say that the risk is exactly ; it provides a higher limit.
3.1.3 A hypothesis fixed before the data
Suppose is chosen without observing . Each variable
It’s Bernoulli, average.
Empirical risk is the average
A concentration inequality can then limit the probability of this average moving away from its hope. For a fixed hypothesis, the sample functions as an opinion poll: more observations make large deviations less likely.
3.1.4 The selection defect
An algorithm does not evaluate just a hypothesis fixed in advance. It uses the data to choose
The hypothesis chosen is a random variable dependent on . Apply a guarantee directly to fixed to ignores this dependency.

Figure 3.1. When comparing many hypotheses, the one selected by the lowest training error may be precisely the one that most benefited from a fluctuation of the sample.
Even if each empirical risk is individually a reasonable estimator, the lowest among many estimators tends to be optimistic. This phenomenon is called selection bias or multiple comparisons effect.
3.1.5 The coin analogy
Imagine honest coins thrown times. For each currency , be it the frequency of faces. Each focuses around .
Now we select
tends to stay below , not because the currency chosen is dishonest, but because we deliberately seek the lowest fluctuation between attempts.
The greater the , the greater the opportunity to observe an extreme value. In learning, hypotheses play the role of coins and empirical error plays the role of the observed frequency.
3.1.6 Uniform control
To allow data-dependent selection, we seek to control all hypotheses simultaneously:
If, for a sample, it is valid
then inequality is valid for any class hypothesis, including that chosen after observing .
This is the reason for a uniform bound. The complexity of appears because controlling more behaviors simultaneously is more difficult.
3.1.7 Decomposition to minimize empirical risk
Whatever.
and be
Suppose the uniform deviation is maximum :
So,
The second inequality uses the fact that minimizes empirical risk.
This derivation shows how uniform convergence transforms empirical minimization into a guarantee of excess risk.
3.1.8 Approximation error and estimation error
Performance can be conceptually separated into:
- approach error: the best hypothesis of may still be inadequate;
- estimation error: finite sample can lead the algorithm to choose a worse hypothesis than the best of class;
- optimization error: the numerical procedure may not find the empirical minimum.
A larger class tends to reduce the approach error, but it can increase the estimation error. More data reduces statistical uncertainty, but does not correct a class that does not represent the pattern.
3.1.9 Overfit as a gap
Overfit occurs when the model takes advantage of specific details of the sample that do not repeat in the population.
The gap can grow when:
- the class has high capacity;
- we compared many configurations;
- the sample is small;
- the data contain noise;
- we repeat decisions using the same validation set.
Regularization, independent validation and capacity control reduce accidental adjustment opportunities, but do not replace representative data.
3.1.10 A non-observable estimate
During training we know , but not , because it depends on . A theoretical bound limits the gap under hypotheses. An independent test set provides another empirical estimate:
Test and theory address the same risk through different paths, both subject to conditions.
Choose and evaluate in the same set
The more decisions are made by looking at a metric, the less this set can be treated as independent evaluation. Overfit can occur in validation, not just in training.
3.1.11 Numerical example
Consider three hypotheses:
| Hypothesis | Training error | Validation error |
|---|---|---|
If we choose only by training, wins. Validation suggests that it has adjusted too much. has less validation error, although it does not have the least training error.
We don’t know the real risk of these hypotheses, but independent data helps detect the discrepancy.
3.1.12 Practice exercises
- Interpret the signal.
- If and the absolute gap is at most , what bound do we get for ?
- Why is the hypothesis chosen by empirical minimization not fixed in relation to the sample?
- Explain the analogy between many currencies and many hypotheses.
- Play the decomposition that leads to .
- Differentiate approach error, estimation and optimization.
- Give an example of overfitting the validation set.
- Why can’t we directly calculate the generalization gap during training?
3.2 Hoeffding’s inequality
Hoeffding inequality controls the deviation between the average of limited random variables and their hope. It is especially useful in learning because many losses are limited and empirical risk is a sample average.
3.2.1 General statement
be independent random variables, with
Set
e
So for ,
When all variables belong to , we get the known form:
Inequality is distribution free: does not require us to know the form of distribution. It requires independence and known limits.

Figure 3.2. As increases, the sample average focuses around hope and the probability of tails outside decreases.
3.2.2 Interpretation
The bound drops exponentially in and :
That means:
- more examples make fixed deviations less likely;
- tolerating a greater deviation makes the warranty easier;
- reducing the desired deviation by half requires approximately four times more examples.
The bound can be larger than for small or very small . As a probability never exceeds , we can write
A bound larger than is valid, but not informative.
3.2.3 Application to a fixed hypothesis
Set a hypothesis before observes the sample. In binary classification, set
Each and, for i.i.d. examples,
The average is exactly the empirical risk:
So,
This is a guarantee for a fixed and independent hypothesis of . The subscribed remembers that randomness is in the sample.
3.2.4 Range form
We want a statement with a probability of failure at most :
Isolating ,
Thus, with the probability of at least ,
Equivalently,
This is a higher bound for the risk of a previously established hypothesis.
3.2.5 Form of sample complexity
We can also isolate . To ensure maximum deviation with confidence , enough
For example, with
We’ve got
Therefore, independent examples are sufficient according to this bound for a fixed hypothesis. It is a guarantee of worse case; it does not say that every application will need exactly that amount.
3.2.6 Numerical example of interval
Suppose a fixed hypothesis evaluated in independent examples, with observed error
For ,
With confidence of at least , Hoeffding guarantees
Bilateral bound also provides lower limit, truncated at zero:
This interval is not necessarily the narrowest for a binomial ratio, but it is simple and does not depend on the unknown value of .
3.2.7 One-sided bound
If we just need to limit the risk above, a one-sided version provides
With a probability of at least ,
The absence of factor slightly improves the bound because we control only one direction of the deviation.
3.2.8 Bounded losses
The application is not restricted to zero-one loss.
We can normalize .
The greater the possible loss interval, the weaker the concentration for the same .
Unlimited losses, such as the quadratic without restriction on predictions and targets, require additional hypotheses or other inequalities. We cannot apply Hoeffding directly without a limit almost certain.
3.2.9 The problem of the chosen hypothesis
In learning, we use
therefore the hypothesis depends on the same sample. The inequality for a fixed cannot be simply rewritten as
This passage would be unjustified: was selected precisely for its behavior in .
We need to control all the hypotheses that the algorithm could choose.
3.2.10 Finite class and union bound
If
So the uniform failure event is
For the sake of unity,
In the complementary event, all hypotheses satisfy the bound. Therefore, any also satisfies.
Note that within the union, each is fixed. The event should not be written with for each plot.
3.2.11 Uniform bound in the form of an interval
Imposing
We get it
With a probability of at least ,
For the selected hypothesis,
The price of examining hypotheses appears as after we isolate .
3.2.12 Sample complexity for finite class
Isolating ,
is sufficient for uniform deviation at most .
If , we recover the bound for a fixed hypothesis. If we multiply the number of hypotheses by a thousand, we add to the numerator, not a thousand factor to the required size.
3.2.13 Example with selection
Consider hypotheses, and . The uniform width is
If the selected hypothesis has empirical error , then
with confidence of at least under the conditions of inequality.
3.2.14 The balance between adjustment and capacity
A larger class may contain a hypothesis with lower empirical error, but increases the complexity penalty:
This suggests an idea of structural risk minimization: compare not only the adjustment, but adjust another capacity penalty.
There is no absolute opposition between “empirical error” and “true error”. The goal is to choose a class expressive enough to represent patterns, but controlled enough to generalize with the available data.
3.2.15 Limitations
Hoeffding doesn’t solve all the problems:
- requires independence;
- requires limited variables;
- the bound may be conservative;
- direct union does not help when is infinite;
- does not treat change of distribution;
- does not correct selection made outside the accounted class.
For infinite classes, we will replace with a measure of the number of relevant behaviors on finite samples. This path leads to growth function and VC dimension.
3.2.16 Computing example
from math import log, sqrt
def radius_hoeffding(n, delta, number_hypothesis=1):
return sqrt(log(2 * number_hypotheses / delta) / (2 *n))
print(radio_hoeffding(1000, 0.05))
print(radio_hoeffding(2000, 0.05, number_hypotheses=100))
The calculation assumes loss in . For loss in , multiply the radius by .
3.2.17 Practice exercises
- Enunciate the conditions of Hoeffding’s inequality.
- Calculate the bilateral bound for and .
- Isolate on .
- How many examples are enough for and in a fixed hypothesis?
- Why does Hoeffding not apply directly to ?
- Draw the bound using the union.
- For , and , calculate the uniform radius.
- Explain why dependence on becomes logarithmic when isolating .
- Give an example of non-limited loss to which Hoeffding cannot be applied directly.
- Compare bilateral and unilateral forms.
3.3 The dimension of Vapnik–Chervonenkis
For a finite class, the uniform Hoeffding bound contains . Important classes, however, have infinite hypotheses: there are infinite straight in the plane and infinite choices of real weights.
The infinite cardinality overestimates the number of relevant behaviors in a finite sample. Two different straight lines can classify the same points exactly the same way. For generalization, it is interesting to count the distinct labels that the class can produce on finite sets.
3.3.1 Restrictions and dichotomy
Be a class of binary classifiers
and a set of distinct points
The restriction to is the vector
The set of dichotomies performed by in is
Although may be infinite,
because there are only binary labels of the points.
Two hypotheses that differ outside , but coincide at all points of , count as a single dichotomy on this set.
3.3.2 Growth function
The growth function is the largest number of dichotomies that the class can perform in any set of points:
It is also common to use the notation. Always goes
The maximum is taken over the position of the dots. A particular set may admit few labels even when another set of the same size admits all.
3.3.3 Shattering
We say shatters when it performs all possible labels:
Equivalently,
The order of quantifiers is essential: we set a single set and demand that for each labeling, there may be a different hypothesis.
If the class shatters any set of points, then
If no set of points is shattered, then
3.3.4 VC dimension
The Vapnik–Chervonenkis dimension is the largest size of a shattered set:
If arbitrarily large sets can be shattered, we define
If is the smallest integer to which
it is called breakpoint. When it exists,
To prove , we need two parts:
- bottom bound: display a set of points that is shattered;
- top bound: prove that no set of points can be shattered.
Finding an impossible labeling in a particular set provides information about that set, but does not alone prove the top bound for all sets.
3.3.5 Example 1: Thresholds on the straight line
Consider
For ordered points,
the threshold can be placed before everyone, between two consecutive points or after all. There are dichotomies:
One point is shattered because we can classify it as or . Two points are not shattered: the labeling contradicts the monotonicity of the threshold.
If we allowed both the threshold guidelines, the class would be different and the count would need to be remade.
3.3.6 Example 2: ranges on the straight line
Now consider positive classifiers within a range:
About ordered points, the positives form a consecutive block.
non-empty blocks and a non-positive labeling.
Two points can receive any of the four labels. Three points cannot perform , because an interval containing the extremes also contains the central point.
3.3.7 Example 3: Lines in the plane
Consider similar semiplanes in :
For any labeling, a line separates the positive from the negative.

Figure 3.3. Rects perform all eight non-collinear three-point labels; XOR labeling in four vertices is a non-separable example.
For the top bound, consider any set of four points.
- If one point is inside the triangle formed by the other three, label the internal point as positive and the others as negative. No semiplane separates it.
- If the four points are in convex position, label alternate vertices as positive. The XOR pattern arises, which is not linearly separable.
- Collinear degenerations do not increase capacity.
So no four-point set is shattered and
For four points in general position, straights perform of the labels: the two XOR labels with opposite diagonals are missing.
3.3.8 Example 4: semiplanes
For similar classifiers
in ,
The bottom bound can be demonstrated using points affin-independent. The top bound results from the dependency in order to any set with points and a separation argument.
When incorporating a constant co-ordinate,
bias becomes part of a vector of weights. This helps to understand the value , but counting parameters is just an intuition, not a general proof of VC dimension.
3.3.9 Example 5: Convex sets in the plane
Consider the class of all convex subsets with positive label within the set.
For any , choose points on a circumference. Given a labeling, take the convex closure of the positive points. No negative point of the circumference belongs to that clasp, because each point is an extreme vertex of the configuration. Cases of all positive or none positive are also feasible.
Therefore, the class shatters sets of any size:
This example shows that a simple geometric description in words can have unlimited capacity.
3.3.10 Comparison of examples
| Class | Growth function | VC dimension |
|---|---|---|
| oriented threshold | ||
| interval | ||
| Semi-plan in | to ; | |
| Semi-plan in | polynomial growth after | |
| Convex sets in | for all |
The growth function contains more information than a single number. The VC dimension identifies the point from which growth is no longer maximum; the next result will show that, after that point, growth is limited by a polynomial in .
3.3.11 VC dimension is not just number of parameters
In some linear models, VC dimension and amount of parameters have the same order. This is not a universal law. Algebraic restrictions, redundant parameters, numerical precision and computational structure change capacity.
In addition, VC dimension measures possible labels, no optimization difficulty, training speed or representation quality.
3.3.12 How to calculate a VC dimension
A practical script is:
- choose candidates for small sets in a favourable position;
- prove that all labels of a size set are feasible;
- consider an arbitrary configuration of points;
- construct, for each possible geometric configuration, at least one impossible labeling;
- complete the lower and upper bounds.
Diagrams help you figure out the answer, but each quantifier needs to appear in the test.
3.3.13 Practice exercises
- List the dichotomies of three ordered points produced by oriented thresholds.
- Check the growth function formula of ranges for .
- Explicitly show how three non-collinear points perform all eight straight labels.
- Explain why the XOR pattern is not linearly separable.
- Complete the top bound argument for four points when one of them is inside the other’s triangle.
- Why points on a circumference can be shattered by convex sets?
- Differentiate growth function, breakpoint and VC dimension.
- Give an example of the statement in which counting parameters would only be heuristic.
3.3.14 Bound of the actual number of hypotheses on a sample
The growth function always satisfies
This bound is accurate when the class shatters some set of points, but it is useless to demonstrate capacity control: replace with in a union bound introduces a linear term in in the exponent and can prevent desired convergence.
The finite VC dimension produces a decisive change. After the first interruption point, the growth function cannot continue exponential; it becomes limited by a polynomial.

Figure 3.4. With finite VC dimension, the growth function ceases to accompany after the break point and is limited by a polynomial sum.
3.3.15 Sauer–Shelah Lemma
If
then, for all ,
We’ve adopted. when - Stop. , the sum
compatible with the possibility of shattering. For , the sum contains only the terms up to and grows as a grade polynomial .
If is the smallest breakpoint, the same bound can be written
3.3.16 Examples of bound
For ,
The class of oriented thresholds reaches exactly this value.
For ,
The range class has
which is greater than Sauer expression with ? Let’s compare carefully:
The expressions are the same. Therefore, intervals also reach Sauer’s bound.
For semi-planes in the plane, :
In ,
The real growth function of related semiplanes in general position is , so the bound is valid but not exact at that point.
3.3.17 Combinatory idea of the proof
Set as the largest number of dichotomies possible in points for a VC dimension class at most . The proof uses recurrence
To understand recurrence, separate the last point . By restricting dichotomies to the first points , there are two types:
- standards that allow only one extension to ;
- standards that admit the two extensions, and .
The first group contributes maximum . In the second group, if it was possible to shatter points between the first , add would produce a set of shattered points. Therefore, the pattern class with two extensions has maximum size and contributes maximum .
Border values are:
e
Applying recurrence repeatedly and using Pascal’s identity,
We get it
This is the central structure of Sauer–Shelah’s test.
3.3.18 Simplified bound
For , it is worth the standard bound
Soon,
Taking logarithms,
This form will be useful in the generalization bound, because the penalty depends on the logarithm of the effective number of dichotomies.
For fixed ,
while
the difference between polynomial and exponential growth is the reason why finite VC dimension allows uniform learning.
3.3.19 An even simpler bound
We can also use, for and , a rough estimate as
It loses constants and refined dependence in , but shows the polynomial degree. expression is usually preferred in quantitative derivations.
3.3.20 Breakpoint and domino effect
The motto contains a strong combinatorial message: it is enough that the class fails to shatter all sets of some finite size so that the entire future growth is controlled.
Can’t have
and then return to maximum growth
for some . If a larger set were shattered, any subset of size would also be shattered, contradicting the breakpoint.
3.3.21 Numerical calculation
Consider and . Sauer–Shelah provides
Calculating,
Without using capacity, the trivial bound would be
The reduction in the effective number of behaviors is enormous.
Simplified bound gives
less accurate than , but still much smaller than .
3.3.22 Relationship with compression of patterns
The sum
subset account of up to elements. This suggests that a VC dimension class cannot make independent decisions in all positions; its patterns are determined by a order combinatorial structure.
This interpretation does not mean that every VC class automatically admits a simple compression scheme with exactly examples. The formal relationship between VC dimension and sample compression is more delicate. The binomial sum is, first of all, a combinatorial bound.
3.3.23 What the lemma does not say
Sauer–Shelah limits the number of dichotomies, but not:
- finds the hypothesis excellent;
- ensures that the algorithm is efficient;
- measures approach error;
- treats continuous regression directly;
- It alone provides a probability of generalization.
To obtain a bound of error, we will combine the growth function with a concentration inequality and a standardization argument.
3.3.24 Computing example
from math import comb
def quota_sauer(n, d):
return sum(n, i) for i in range(min(d, n) + 1)
print(quota_sauer(20, 3)) #1351
print(2 ** 20) # 1048576
3.3.25 Practice exercises
- Calculate Sauer’s bound for and .
- Check that the formula for matches the threshold growth function.
- Show algebraically that .
- Explain the recurrence .
- Use Pascal’s identity to verify that the binomial sum satisfies the same recurrence.
- Compare numerically and Sauer’s bound for , .
- Why can’t a class reshape larger sets after a breakpoint?
- Differentiate the exact bound by the binomial sum of the approach.
- Explain why Sauer–Shelah’s motto is not yet a bound of generalization on its own.
3.3.26 Error bound
So far, the VC dimension and growth function have measured how many ** different ways a class of hypotheses can produce on a sample**. There is a need to transform this combinatorial measure into a statement statistics: how close the error observed in the data is to the error that the will you have a chance in future examples?
Whatever.
where is the error in the training sample and is the expected error in the distribution that generates the data. The module is called generalization gap.

Figure 3.5. The VC dimension limits the growth function, which allows simultaneously to control the gap of all hypotheses.
A uniform bound
A classic form of Vapnik-Chervonenkis inequality states that, for any ,
Constants may vary between versions of the theorem, but the structure is always the same: a portion measures the complexity of and the exponential measures the beneficial effect of the number of examples.
The supreme is essential. Inequality does not control just one hypothesis fixed before observing the data; it controls all ** simultaneously the class** hypotheses. Therefore, it remains valid for the hypothesis chosen by algorithm after examining sample. precisely the step that a direct application of inequality of the Hoeffding can’t justify it.
Setting a probability of failure and isolating in (3.1), we get, with at least probability ,
In particular, the hypothesis returned by the algorithm satisfies
Thus, the bound separates two objectives: the algorithm seeks to reduce , while the theory limits the distance between this value and .
Inserting VC dimension
If , Sauer–Shelah’s motto provides
Replacing this estimate in (3.2), we arrived at the bound
This expression explains three important relationships:
- increase tends to narrow the bound;
- increase makes the class more flexible and widens the bound;
- reducing increases confidence, but also makes the warranty more conservative.
For fixed , the right side has approximate order
which converges to zero when . Convergence occurs because the growth function is polynomial. if it remained equal to , its logarithm would be proportional to and the bound would not It would disappear.
How many examples are needed?
To require a gap of maximum , just look for such that
The inequality is implicit, as also appears within the logarithm. In a program, we can find the smallest integer that the satisfies by incremental or binary search. A fixed point iteration also provides a quick estimate:
import math
def amostras_vc(d, epsilon, delta, n_inicial=1):
n = max(n_inicial, math.ceil(d / 2))
while True:
rhs = (8 / epsilon**2) * (
d * math.log(2 * math.e * n / d)
+ math.log(4 / delta)
)
novo_n = math.ceil(rhs)
if novo_n <= n:
return n
n = novo_n
print(amostras_vc(d=3, epsilon=0.1, delta=0.1))
The result should be interpreted as a sufficient condition, no as the exact number of examples that every problem will need. VC bounds they are independent of distribution and algorithm; for covering up to more unfavorable cases are often conservative.
VC dimension is not just number of parameters
In some linear models, the VC dimension is close to the number of free parameters. This does not constitute a universal rule. architecture, margin, regularization and even the form of parameterization can The relevant mathematical object is the class of performable functions, not just the size of the parameter vector.
From generalization to PAC learning
Suppose the algorithm finds with small training error. If the class has finite VC dimension and satisfies (3.4), then with high probability, the error was out The sample will also be small. perfect hypothesis in the class and the algorithm finds , (3.3) directly provides a warranty for .
In the case of non-realisable, it is useful to decompose performance into two parts:
The VC theory controls the second part; optimization and model choice A narrow bound does not compensate for a model that adjusts data as well as zero training error does not guarantee alone Good generalization.
Example of bound reading
Consider two classes trained with the same sample. has and the class has . If both achieve the same training error, the bound favors , because it offers less ways to accidentally adapt to noise. However, if presents very high training error, can produce the best sum between adjustment and complexity. This tension is a mathematical formulation of the compromise between underfit and overfit.
Review
- The inequality VC evenly controls all the hypotheses of .
- Sauer–Shelah’s motto converts finite VC dimension into growth polynomial.
- The guaranteed gap decreases approximately as .
- Sample complexity grows with capacity, with precision desired and with desired confidence .
- The bound is a guarantee of worse case; it guides reasoning, but it does not replaces empirical validation.
Exercises
- Explain why the supreme over allows you to apply the quotes the hypothesis chosen after observing the data.
- Keeping and fixed, what happens approximately with the bound when is quadrupled?
- Implement the
amostras_vcfunction and compare the results to . - Show that, for fixed, .
- Give an example in which to choose the smaller VC class provokes Underfit.
3.4 Multiple choice exercises
Each question has a single correct answer. Try to relate the alternative chosen to the definitions and bounds studied in the chapter.
-
The absolute generalization gap of a hypothesis is:
- .
- .
- .
- the number of parameters of .
-
Because a bound for a pre-data hypothesis is not enough for the hypothesis selected by training?
- Because the training chooses the hypothesis based on the same sample.
- Because trained hypotheses have no mistake.
- Because the sample no longer contains random variables.
- Because Hoeffding applies only to regression.
-
The Hoeffding inequality, in the studied form, requires variables:
- independent and limited.
- always Gaussian and negative.
- deterministic and unlimited.
- necessarily vectorial.
-
When quadrupling , maintaining the other fixed terms , a proportional bound the is approximately:
- duplicate.
- reduced to half.
- quadrupled.
- unchanged.
-
For a finite class with hypotheses, the union bound typically introduces What dependence on complexity?
- .
- .
- within the error.
- No dependency on .
-
A set is shattered by when:
- only a labeling can be produced.
- all binary labels of their points can be performed by chances of .
- all points must be labelled as the same.
- his cardinality is infinite.
-
The VC dimension of the threshold class in a straight line is:
-
-
-
- Infinite.
-
-
The VC dimension of the range class in a straight line is:
-
-
-
- Infinite.
-
-
Sauer–Shelah’s motto shows that when is finite, the function of growth for large samples is limited by a growth:
- polynomial in .
- necessarily constant.
- greater than all exponentials.
- independent of .
-
What statement correctly interprets a VC bound?
- It predicts exactly the test error of any experiment.
- It is a guarantee of worse case and does not replace empirical validation.
- It proves that simpler models are always better.
- It eliminates the error of approach.
Answer key with explanations
- a. The absolute value measures the size of the difference without depending on its signal.
- a. Selection adapts to sample fluctuations, requiring control Simultaneous over the whole class.
- a. Independence and limitation are central conditions of the presented form.
- b. .
- a. The application of the union to hypotheses appears as by isolating the tolerance.
- b. Shrapnel means performing the possible dichotomies on that set.
- b. One point may receive both labels, but two points do not admit all dichotomy with a single oriented threshold.
- b. Ranges shatter two points; three alternate points cannot be positive-negative-positive labelled for one interval only.
- a. For , the effective number of dichotomies ceases to grow as and receives a polynomial bound.
- b. The bound explains dependencies and offers probabilistic warranty but can be conservative in a concrete application.