Documentation

CslibFrontier.MachineLearning.Rademacher.Generalization

Rademacher generalization bounds #

For a class F of functions from a finite domain Z into [a, b] and a sample S of m independent draws from a distribution D, the population mean ∑ z, D z f z of every f ∈ F exceeds its empirical mean đ”ŧ i, f (S i) by at most twice the Rademacher complexity plus a deviation term. With probability at least 1 - δ, for all f ∈ F,

[MohriRostamizadehTalwalkar2018, Theorem 3.3] (stated there for [0, 1]-valued classes, the case a = 0, b = 1); see also [ShalevShwartzBenDavid2014, Chapter 26], and cf. [BartlettMendelson2002, Theorem 8], a variant for loss classes with a different normalization of the Rademacher complexity and different constants. The second bound is data-dependent: its complexity term can be computed from the sample.

The proof has two parts.

Probabilities are the outer measures of the finite product distribution Cslib.Probability.PMF.pi, and each theorem bounds the probability of the failure event by δ.

Main results #

References #

Boundedness helpers #

Symmetrization #

theorem Cslib.MachineLearning.sum_pi_mul_ciSup_sub_le_two_mul_rademacherComplexity {Z : Type u_1} [Fintype Z] (D : PMF Z) {m : ℕ} (hm : 0 < m) {F : Set (Z → ℝ)} {B : ℝ} (hF : ∀ f ∈ F, ∀ (z : Z), |f z| ≤ B) :
(∑ S : Fin m → Z, ((Probability.PMF.pi fun (x : Fin m) => D) S).toReal * ⨆ (f : ↑F), ∑ z : Z, (D z).toReal * ↑f z - Finset.univ.expect fun (i : Fin m) => ↑f (S i)) ≤ 2 * rademacherComplexity D F m

Symmetrization [MohriRostamizadehTalwalkar2018, (3.8)–(3.13)]: for a class bounded by B and samples of size m > 0, the expected worst-case gap between population and empirical means is at most twice the Rademacher complexity, đ”ŧ_S sup_{f ∈ F} (E_D f - Ê_S f) ≤ 2 R_m(F).

Bounded differences #

theorem Cslib.MachineLearning.hasBoundedDifferences_empiricalRademacherComplexity {Z : Type u_1} {m : ℕ} {F : Set (Z → ℝ)} {a b : ℝ} (hab : a ≤ b) (hF : ∀ f ∈ F, ∀ (z : Z), f z ∈ Set.Icc a b) :
Probability.HasBoundedDifferences (fun (S : Fin m → Z) => empiricalRademacherComplexity F S) fun (x : Fin m) => (b - a) / ↑m

The empirical Rademacher complexity of a class with values in [a, b] has bounded differences (b - a) / m as a function of the sample [MohriRostamizadehTalwalkar2018, proof of Theorem 3.3].

Generalization bounds #

theorem Cslib.MachineLearning.rademacherComplexity_generalization_bound {Z : Type u_1} [Fintype Z] (D : PMF Z) {m : ℕ} (hm : 0 < m) {F : Set (Z → ℝ)} {a b : ℝ} (hab : a < b) (hF : ∀ f ∈ F, ∀ (z : Z), f z ∈ Set.Icc a b) {δ : ℝ} (hδ : 0 < δ) :
((Probability.PMF.pi fun (x : Fin m) => D).toOuterMeasure {S : Fin m → Z | ∃ f ∈ F, (Finset.univ.expect fun (i : Fin m) => f (S i)) + 2 * rademacherComplexity D F m + (b - a) * √(Real.log (1 / δ) / (2 * ↑m)) < ∑ z : Z, (D z).toReal * f z}).toReal ≤ δ

Rademacher generalization bound [MohriRostamizadehTalwalkar2018, Theorem 3.3, (3.3)]: for a class F of functions with values in [a, b] and m > 0 independent draws from D, the probability that some f ∈ F has E_D f > Ê_S f + 2 R_m(F) + (b - a) √(log (1 / δ) / (2 m)) is at most δ. The source states the case [a, b] = [0, 1].

theorem Cslib.MachineLearning.empiricalRademacherComplexity_generalization_bound {Z : Type u_1} [Fintype Z] (D : PMF Z) {m : ℕ} (hm : 0 < m) {F : Set (Z → ℝ)} {a b : ℝ} (hab : a < b) (hF : ∀ f ∈ F, ∀ (z : Z), f z ∈ Set.Icc a b) {δ : ℝ} (hδ : 0 < δ) :
((Probability.PMF.pi fun (x : Fin m) => D).toOuterMeasure {S : Fin m → Z | ∃ f ∈ F, (Finset.univ.expect fun (i : Fin m) => f (S i)) + 2 * empiricalRademacherComplexity F S + 3 * ((b - a) * √(Real.log (2 / δ) / (2 * ↑m))) < ∑ z : Z, (D z).toReal * f z}).toReal ≤ δ

Data-dependent Rademacher generalization bound [MohriRostamizadehTalwalkar2018, Theorem 3.3, (3.4)]: for a class F of functions with values in [a, b] and m > 0 independent draws from D, the probability that some f ∈ F has E_D f > Ê_S f + 2 RĖ‚_S(F) + 3 (b - a) √(log (2 / δ) / (2 m)) is at most δ. The source states the case [a, b] = [0, 1]. The proof combines the expected bound at confidence δ / 2 with McDiarmid's lower tail for RĖ‚_S(F) at confidence δ / 2.

theorem Cslib.MachineLearning.rademacher_generalization_bound_of_finset {Z : Type u_1} [Fintype Z] (D : PMF Z) {m : ℕ} (hm : 0 < m) {F : Finset (Z → ℝ)} (hF : ∀ f ∈ F, ∀ (z : Z), f z ∈ Set.Icc 0 1) {δ : ℝ} (hδ : 0 < δ) :
((Probability.PMF.pi fun (x : Fin m) => D).toOuterMeasure {S : Fin m → Z | ∃ f ∈ F, (Finset.univ.expect fun (i : Fin m) => f (S i)) + 2 * √(2 * Real.log ↑F.card / ↑m) + √(Real.log (1 / δ) / (2 * ↑m)) < ∑ z : Z, (D z).toReal * f z}).toReal ≤ δ

Generalization bound for a finite class with values in [0, 1], through Massart's lemma: the probability that some f ∈ F has E_D f > Ê_S f + 2 √(2 log |F| / m) + √(log (1 / δ) / (2 m)) is at most δ [MohriRostamizadehTalwalkar2018, Theorem 3.3 and Theorem 3.7]. This illustrates the method; Hoeffding's inequality with a union bound gives the sharper √(log (|F| / δ) / (2 m)).