文章

Generalization Bound and Complexity

·

In this blog, we talk about the generalization ability of function class in machine learning. We assume that readers have basic knowledge of machine learning.

Generalization Bound and Complexity

Mipha
(August 17, 2026)

1 Introduction

In this blog, we talk about the generalization ability of function class in machine learning. We assume that readers have basic knowledge of machine learning.

2 Risk and Empirical Risk Minimization

Definition 1 (Population Risk).

The population risk of a hypothesis ℎ is defined as

𝑅(ℎ)=𝔼(𝑥,𝑦)∼D[ℓ(ℎ(𝑥),𝑦)],

where ℓ is the loss function and D is the data distribution.

Definition 2 (Empirical Risk).

The empirical risk of a hypothesis ℎ is defined as

ˆ𝑅(ℎ)=1𝑛𝑛∑𝑖=1ℓ(ℎ(𝑥𝑖),𝑦𝑖),

where (𝑥𝑖,𝑦𝑖) are i.i.d. samples from D and 𝑛 is the number of samples.

In generalization theory, our goal is to minimize the population risk 𝑅(𝑓), or equivalently, to minimize the excess risk 𝑅(𝑓)−𝑅(𝑓∗), where 𝑓∗ is the Bayes optimal predictor. However, since we do not have access to the data distribution D, we can only minimize the empirical risk ˆ𝑅(𝑓) based on the training data. Therefore, we need to analyze the relationship between the population risk and the empirical risk, which is known as generalization analysis.

Definition 3 (ERM).

Empirical Risk Minimization (ERM) is a learning paradigm that aims to find a hypothesis ˆ𝑓 that minimizes the empirical risk ˆ𝑅(𝑓) over a hypothesis class F:

ˆ𝑓=arg⁡min𝑓∈Hˆ𝑅(𝑓).
Proposition 4 (Risk Minimization Decomposition).

The excess risk can be decomposed as follows:

𝑅(ˆ𝑓)−𝑅(𝑓∗)=(𝑅(ˆ𝑓)−inf𝑓′∈F𝑅(𝑓′))⏟____⏟____⏟Estimation Error+(inf𝑓′∈F𝑅(𝑓′)−𝑅(𝑓∗))⏟_____⏟_____⏟Approximation Error.

The estimation error is often further decomposed using 𝑔F∈arg⁡min𝑓∈F𝑅(𝑓) as the best-in-class predictor:

𝑅(ˆ𝑓)−inf𝑓′∈F𝑅(𝑓′)=𝑅(ˆ𝑓)−𝑅(𝑔F)=(𝑅(ˆ𝑓)−ˆ𝑅(ˆ𝑓))+(ˆ𝑅(ˆ𝑓)−ˆ𝑅(𝑔F))+(ˆ𝑅(𝑔F)−𝑅(𝑔F))≤sup𝑓∈F(𝑅(𝑓)−ˆ𝑅(𝑓))+0+sup𝑓∈F(ˆ𝑅(𝑓)−𝑅(𝑓))≤2sup𝑓∈F∣𝑅(𝑓)−ˆ𝑅(𝑓)∣

3 Generalization Bounds

Theorem 5 (Uniform Bound for Finite Models).

We assume loss functions from F are bounded between 0 and 𝑙∞. For any 𝛿∈(0,1), with probability greater than 1−𝛿, we have:

sup𝑓∈F∣𝑅(𝑓)−ˆ𝑅(𝑓)∣≤𝑙∞√log⁡(2|F|)2𝑛+𝑙∞√2𝑛√log⁡1𝛿

Proof.

For any fixed 𝑓∈F, Hoeffding’s inequality gives

ℙ(∣𝑅(𝑓)−̂𝑅(𝑓)∣>𝑡)≤2exp⁡(−2𝑛𝑡2𝑙2∞).

Applying the union bound over F,

ℙ(sup𝑓∈F∣𝑅(𝑓)−̂𝑅(𝑓)∣>𝑡)≤2|F|exp⁡(−2𝑛𝑡2𝑙2∞).

Setting the right-hand side equal to 𝛿 yields

𝑡=𝑙∞√log⁡(2|F|)+log⁡(1/𝛿)2𝑛.

Using √𝑎+𝑏≤√𝑎+√𝑏, we obtain, with probability at least 1−𝛿,

sup𝑓∈F∣𝑅(𝑓)−̂𝑅(𝑓)∣≤𝑙∞√log⁡(2|F|)2𝑛+𝑙∞√2𝑛√log⁡1𝛿.

∎

Remark 6.

We can not say that ∣𝑅(ˆ𝑓)−ˆ𝑅(ˆ𝑓)∣ can be bounded as well since ˆ𝑅 is data-depended and thus we can’t apply Hoeffding’s inequality.

Definition 7 (Covering Number).

We assume that for 𝜀>0 there are 𝑚=𝑚(𝜀) elements 𝑓1,…𝑓𝑚∈F such that for any 𝑓∈F, there exists 𝑖∈[𝑚], Δ(𝑓,𝑓𝑖)≤𝜀. Here, 𝑚(𝜀) is called the covering number of F.

Theorem 8 (Uniform Bound for Infinite Models).

We assume the loss function is G-Lipschitz with respect to the second argument and is bounded between 0 and 𝑙∞. 𝑚(𝜀) is the covering number with respect to 𝜀>0. For any 𝛿∈(0,1), with probability greater than 1−𝛿, we have:

sup𝑓∈F∣𝑅(𝑓)−ˆ𝑅(𝑓)∣≤2𝐺𝜀+𝑙∞√log⁡(2𝑚(𝜀))2𝑛+𝑙∞√2𝑛√log⁡1𝛿

Proof.

Let {𝑓1,…,𝑓𝑚} be an 𝜀-cover of F, where 𝑚=𝑚(𝜀). For every 𝑓∈F, choose 𝑓𝑖 such that

Δ(𝑓,𝑓𝑖)≤𝜀.

By the 𝐺-Lipschitz property,

|𝑅(𝑓)−𝑅(𝑓𝑖)|≤𝐺Δ(𝑓,𝑓𝑖)≤𝐺𝜀,

and similarly,

|̂𝑅(𝑓)−̂𝑅(𝑓𝑖)|≤𝐺Δ(𝑓,𝑓𝑖)≤𝐺𝜀.

Hence,

|𝑅(𝑓)−̂𝑅(𝑓)|≤|𝑅(𝑓)−𝑅(𝑓𝑖)|+|𝑅(𝑓𝑖)−̂𝑅(𝑓𝑖)|+|̂𝑅(𝑓𝑖)−̂𝑅(𝑓)|≤2𝐺𝜀+|𝑅(𝑓𝑖)−̂𝑅(𝑓𝑖)|.

Therefore,

sup𝑓∈F|𝑅(𝑓)−̂𝑅(𝑓)|≤2𝐺𝜀+max𝑖∈[𝑚]|𝑅(𝑓𝑖)−̂𝑅(𝑓𝑖)|.

Applying the finite-model bound to {𝑓1,…,𝑓𝑚}, with probability at least 1−𝛿,

max𝑖∈[𝑚]|𝑅(𝑓𝑖)−̂𝑅(𝑓𝑖)|≤𝑙∞√log⁡(2𝑚)2𝑛+𝑙∞√2𝑛√log⁡1𝛿.

Substituting 𝑚=𝑚(𝜀) proves the result. ∎

4 Rademacher Complexity

Definition 9 (Rademacher Complexity).

Let 𝑆=(𝑍1,…,𝑍𝑛) be an i.i.d. sample and let 𝜎1,…,𝜎𝑛 be independent Rademacher random variables, i.e.,

ℙ(𝜎𝑖=1)=ℙ(𝜎𝑖=−1)=12.

For a function class H, its empirical Rademacher complexity is

̂ℜ𝑆(H):=𝔼𝜎[supℎ∈H∣1𝑛𝑛∑𝑖=1𝜎𝑖ℎ(𝑍𝑖)∣].

Its expected Rademacher complexity is

ℜ𝑛(H):=𝔼𝑆[̂ℜ𝑆(H)].

For the risk 𝑅(𝑓)=𝔼[ℓ(𝑌,𝑓(𝑋))], we take

H=ℓ∘F:={(𝑥,𝑦)↦ℓ(𝑦,𝑓(𝑥)):𝑓∈F}.
Proposition 10 (Symmetrization).

Let 𝑆=(𝑍1,…,𝑍𝑛) be an i.i.d. sample. Then

𝔼𝑆[sup𝑓∈F∣𝑅(𝑓)−̂𝑅(𝑓)∣]≤2ℜ𝑛(ℓ∘F).

Proof.

Let 𝑆′=(𝑍′1,…,𝑍′𝑛) be an independent copy of 𝑆. Then

𝔼𝑆sup𝑓∈F|𝑅(𝑓)−̂𝑅(𝑓)|≤𝔼𝑆,𝑆′sup𝑓∈F∣1𝑛𝑛∑𝑖=1(ℓ𝑓(𝑍′𝑖)−ℓ𝑓(𝑍𝑖))∣=𝔼𝑆,𝑆′,𝜎sup𝑓∈F∣1𝑛𝑛∑𝑖=1𝜎𝑖(ℓ𝑓(𝑍′𝑖)−ℓ𝑓(𝑍𝑖))∣≤2ℜ𝑛(ℓ∘F),

where ℓ𝑓(𝑥,𝑦):=ℓ(𝑦,𝑓(𝑥)). ∎

Theorem 11 (Generalization Bound for Rademacher Complexity).

Assume that

0≤ℓ(𝑦,𝑓(𝑥))≤𝑙∞

for every 𝑓∈F. For any 𝛿∈(0,1), with probability at least 1−𝛿,

sup𝑓∈F∣𝑅(𝑓)−̂𝑅(𝑓)∣≤2ℜ𝑛(ℓ∘F)+𝑙∞√log⁡(1/𝛿)2𝑛.

Proof.

Define

Φ(𝑆):=sup𝑓∈F|𝑅(𝑓)−̂𝑅(𝑓)|.

Replacing one observation changes Φ(𝑆) by at most 𝑙∞/𝑛. Hence, by McDiarmid’s inequality,

Φ(𝑆)≤𝔼𝑆[Φ(𝑆)]+𝑙∞√log⁡(1/𝛿)2𝑛

with probability at least 1−𝛿. By symmetrization,

𝔼𝑆[Φ(𝑆)]≤2ℜ𝑛(ℓ∘F),

which proves the result. ∎

Theorem 12 (Generalization Bound for Rademacher Complexity(Empirical)).

Assume that

0≤ℓ(𝑦,𝑓(𝑥))≤𝑙∞

for every 𝑓∈F. For any 𝛿∈(0,1), with probability at least 1−𝛿,

sup𝑓∈F∣𝑅(𝑓)−̂𝑅(𝑓)∣≤2̂ℜ𝑆(ℓ∘F)+3𝑙∞√log⁡(2/𝛿)2𝑛.

Proof.

By the preceding theorem, with probability at least 1−𝛿/2,

sup𝑓∈F|𝑅(𝑓)−̂𝑅(𝑓)|≤2ℜ𝑛(ℓ∘F)+𝑙∞√log⁡(2/𝛿)2𝑛.

Moreover, bounded differences gives, with probability at least 1−𝛿/2,

ℜ𝑛(ℓ∘F)≤̂ℜ𝑆(ℓ∘F)+𝑙∞√log⁡(2/𝛿)2𝑛.

Combining the two inequalities and applying the union bound yields

sup𝑓∈F|𝑅(𝑓)−̂𝑅(𝑓)|≤2̂ℜ𝑆(ℓ∘F)+3𝑙∞√log⁡(2/𝛿)2𝑛.

∎

References