Documentation

CslibFrontier.MachineLearning.Rademacher.Classification

Rademacher bounds for binary classification #

For a binary concept class C on a finite domain α and a distribution D on labeled examples α × Bool, the 0-1 losses (x, y) ↦ 𝟙[h x ≠ y] of the concepts h ∈ C form the class bitClass (lossClass C) of {0, 1}-valued functions. Its empirical Rademacher complexity on a labeled sample S is half that of the sign class signClass C on the unlabeled points of S [MohriRostamizadehTalwalkar2018, Lemma 3.4]; taking expectations, its Rademacher complexity under D is half that of signClass C under the marginal D.map Prod.fst. With the general Rademacher generalization bound (CslibFrontier.MachineLearning.Rademacher.Generalization) this gives, with probability at least 1 - δ over m independent examples, for every h ∈ C,

err_D(h) ≤ err_S(h) + R_m(signClass C) + √(log (1 / δ) / (2 m))

[MohriRostamizadehTalwalkar2018, Theorem 3.5], where err_D(h) is the probability that h misclassifies an example drawn from D and err_S(h) is its empirical error on S. Bounding the Rademacher complexity by the growth function or through Sauer's lemma gives the growth-function and VC-dimension generalization bounds [MohriRostamizadehTalwalkar2018, Corollaries 3.9 and 3.19].

For an empirical risk minimizer A for C, the uniform bound at confidence δ / 2 and the Rademacher bound for a single comparator at confidence δ / 2 give the agnostic guarantee err_D(A S) ≤ err_D(c) + R_m(signClass C) + √(2 log (2 / δ) / m) for every c ∈ C, and thus the VC-dimension rate √(2 d log (e m / d) / m) + √(2 log (2 / δ) / m) against the best concept of C. The comparator bound is Hoeffding's inequality, obtained here from the generalization bound for the singleton class {-𝟙[c x ≠ y]}, whose Rademacher complexity is 0.

The domain is a finite type, so that distributions are probability mass functions and the finite McDiarmid inequality applies; the source states the results for an arbitrary input space. Probabilities are the outer measures of the product mass function Probability.PMF.pi, true errors are (D.toOuterMeasure {p | h p.1 ≠ p.2}).toReal, and empirical errors are empiricalMiscount h S / m.

Main definitions #

Main results #

References #

The 0-1 loss class #

The {0, 1}-valued functions x ↦ bitVal ℝ (c x) of a binary concept class C. Applied to lossClass C, these are the 0-1 losses (x, y) ↦ 𝟙[h x ≠ y] of the concepts h ∈ C.

theorem Cslib.MachineLearning.mem_bitClass {α : Type u_1} {C : PACLearning.ConceptClass α Bool} {f : α → ℝ} :
f ∈ bitClass C ↔ ∃ c ∈ C, (fun (x : α) => BitString.bitVal ℝ (c x)) = f
theorem Cslib.MachineLearning.mem_bitClass_lossClass {α : Type u_1} {C : PACLearning.ConceptClass α Bool} {f : α × Bool → ℝ} :
f ∈ bitClass (PACLearning.lossClass C) ↔ ∃ h ∈ C, (fun (p : α × Bool) => BitString.bitVal ℝ (decide (h p.1 ≠ p.2))) = f

The 0-1 losses of the concepts of C as functions on labeled examples.

theorem Cslib.MachineLearning.mem_Icc_of_mem_bitClass {α : Type u_1} {C : PACLearning.ConceptClass α Bool} {f : α → ℝ} (hf : f ∈ bitClass C) (x : α) :
f x ∈ Set.Icc 0 1

Functions of bitClass C take values in [0, 1].

The 0-1 loss class [MohriRostamizadehTalwalkar2018, Lemma 3.4]: on a labeled sample S, the empirical Rademacher complexity of the 0-1 losses of C is half that of signClass C on the unlabeled points x_i = (S i).1.

theorem Cslib.MachineLearning.expect_bitVal_decide_ne {α : Type u_1} {m : ℕ} (h : α → Bool) (S : Fin m → α × Bool) :
(Finset.univ.expect fun (i : Fin m) => BitString.bitVal ℝ (decide (h (S i).1 ≠ (S i).2))) = ↑(PACLearning.empiricalMiscount h S) / ↑m

The average 0-1 loss on a labeled sample is the empirical error empiricalMiscount h S / m.

The 0-1 loss class, in expectation [MohriRostamizadehTalwalkar2018, Lemma 3.4 and the remark after it]: under a distribution D on labeled examples, the Rademacher complexity of the 0-1 losses of C is half that of signClass C under the marginal distribution D.map Prod.fst of the unlabeled points.

theorem Cslib.MachineLearning.sum_mul_bitVal_decide_ne {α : Type u_1} [Fintype α] (D : PMF (α × Bool)) (h : α → Bool) :
∑ p : α × Bool, (D p).toReal * BitString.bitVal ℝ (decide (h p.1 ≠ p.2)) = (D.toOuterMeasure {p : α × Bool | h p.1 ≠ p.2}).toReal

The expected 0-1 loss under D is the probability that h misclassifies an example drawn from D.

Generalization bounds #

theorem Cslib.MachineLearning.rademacherComplexity_classification_bound {α : Type u_1} [Fintype α] (D : PMF (α × Bool)) {m : ℕ} (hm : 0 < m) (C : PACLearning.ConceptClass α Bool) {δ : ℝ} (hδ : 0 < δ) :
((Probability.PMF.pi fun (x : Fin m) => D).toOuterMeasure {S : Fin m → α × Bool | ∃ h ∈ C, ↑(PACLearning.empiricalMiscount h S) / ↑m + rademacherComplexity (PMF.map Prod.fst D) (signClass C) m + √(Real.log (1 / δ) / (2 * ↑m)) < (D.toOuterMeasure {p : α × Bool | h p.1 ≠ p.2}).toReal}).toReal ≤ δ

Rademacher bound for binary classification [MohriRostamizadehTalwalkar2018, Theorem 3.5, (3.17)]: with probability at least 1 - δ over m > 0 independent examples from D, every h ∈ C satisfies err_D(h) ≤ err_S(h) + R_m(signClass C) + √(log (1 / δ) / (2 m)), where the Rademacher complexity is taken under the marginal D.map Prod.fst. The domain is finite.

theorem Cslib.MachineLearning.empiricalRademacherComplexity_classification_bound {α : Type u_1} [Finite α] (D : PMF (α × Bool)) {m : ℕ} (hm : 0 < m) (C : PACLearning.ConceptClass α Bool) {δ : ℝ} (hδ : 0 < δ) :
((Probability.PMF.pi fun (x : Fin m) => D).toOuterMeasure {S : Fin m → α × Bool | ∃ h ∈ C, (↑(PACLearning.empiricalMiscount h S) / ↑m + empiricalRademacherComplexity (signClass C) fun (i : Fin m) => (S i).1) + 3 * √(Real.log (2 / δ) / (2 * ↑m)) < (D.toOuterMeasure {p : α × Bool | h p.1 ≠ p.2}).toReal}).toReal ≤ δ

Data-dependent Rademacher bound for binary classification [MohriRostamizadehTalwalkar2018, Theorem 3.5, (3.18)]: with probability at least 1 - δ over m > 0 independent examples from D, every h ∈ C satisfies err_D(h) ≤ err_S(h) + R̂_{S_X}(signClass C) + 3 √(log (2 / δ) / (2 m)), where S_X is the sequence of unlabeled points of S. The domain is finite.

theorem Cslib.MachineLearning.growthFunction_classification_bound {α : Type u_1} [Finite α] (D : PMF (α × Bool)) {m : ℕ} (hm : 0 < m) (C : PACLearning.ConceptClass α Bool) {δ : ℝ} (hδ : 0 < δ) :
((Probability.PMF.pi fun (x : Fin m) => D).toOuterMeasure {S : Fin m → α × Bool | ∃ h ∈ C, ↑(PACLearning.empiricalMiscount h S) / ↑m + √(2 * Real.log ↑(PACLearning.growthFunction C m) / ↑m) + √(Real.log (1 / δ) / (2 * ↑m)) < (D.toOuterMeasure {p : α × Bool | h p.1 ≠ p.2}).toReal}).toReal ≤ δ

Growth-function generalization bound [MohriRostamizadehTalwalkar2018, Corollary 3.9]: with probability at least 1 - δ over m > 0 independent examples from D, every h ∈ C satisfies err_D(h) ≤ err_S(h) + √(2 log Π_C(m) / m) + √(log (1 / δ) / (2 m)). The domain is finite.

theorem Cslib.MachineLearning.vc_classification_bound {α : Type u_1} [Finite α] (D : PMF (α × Bool)) {C : PACLearning.ConceptClass α Bool} {d : ℕ} (hC : ∀ (W : Finset α), PACLearning.SetShatters C ↑W → W.card ≤ d) {m : ℕ} (hm : 0 < m) (hdm : d ≤ m) {δ : ℝ} (hδ : 0 < δ) :
((Probability.PMF.pi fun (x : Fin m) => D).toOuterMeasure {S : Fin m → α × Bool | ∃ h ∈ C, ↑(PACLearning.empiricalMiscount h S) / ↑m + √(2 * (↑d * Real.log (Real.exp 1 * ↑m / ↑d)) / ↑m) + √(Real.log (1 / δ) / (2 * ↑m)) < (D.toOuterMeasure {p : α × Bool | h p.1 ≠ p.2}).toReal}).toReal ≤ δ

VC-dimension generalization bound [MohriRostamizadehTalwalkar2018, Corollary 3.19]: if every finite set shattered by C has at most d points, then for m ≥ d and m > 0, with probability at least 1 - δ over m independent examples from D, every h ∈ C satisfies err_D(h) ≤ err_S(h) + √(2 d log (e m / d) / m) + √(log (1 / δ) / (2 m)). The source assumes m ≥ d implicitly through Corollary 3.18. The domain is finite.

Empirical risk minimization #

theorem Cslib.MachineLearning.PACLearning.IsERM.rademacherComplexity_agnostic_bound {α : Type u_1} [Fintype α] (D : PMF (α × Bool)) {m : ℕ} (hm : 0 < m) {C : ConceptClass α Bool} {A : Learner α Bool m} (hA : IsERM A C) {δ : ℝ} (hδ : 0 < δ) :
((Probability.PMF.pi fun (x : Fin m) => D).toOuterMeasure {S : Fin m → α × Bool | ∃ c ∈ C, (D.toOuterMeasure {p : α × Bool | c p.1 ≠ p.2}).toReal + rademacherComplexity (PMF.map Prod.fst D) (signClass C) m + √(2 * Real.log (2 / δ) / ↑m) < (D.toOuterMeasure {p : α × Bool | A S p.1 ≠ p.2}).toReal}).toReal ≤ δ

Agnostic learning by empirical risk minimization: with probability at least 1 - δ over m > 0 independent examples from D, an empirical risk minimizer A for C satisfies err_D(A S) ≤ err_D(c) + R_m(signClass C) + √(2 log (2 / δ) / m) simultaneously for every c ∈ C, that is, it is within this margin of the best concept of C. The Rademacher complexity is taken under the marginal D.map Prod.fst. This combines (3.17) of [MohriRostamizadehTalwalkar2018, Theorem 3.5] at confidence δ / 2 with Hoeffding's upper tail for a best concept at confidence δ / 2; compare the agnostic analysis of [ShalevShwartzBenDavid2014, Chapter 26], whose constants differ. The domain is finite.

theorem Cslib.MachineLearning.PACLearning.IsERM.vc_agnostic_bound {α : Type u_1} [Finite α] (D : PMF (α × Bool)) {C : ConceptClass α Bool} {d : ℕ} (hC : ∀ (W : Finset α), SetShatters C ↑W → W.card ≤ d) {m : ℕ} (hm : 0 < m) (hdm : d ≤ m) {A : Learner α Bool m} (hA : IsERM A C) {δ : ℝ} (hδ : 0 < δ) :
((Probability.PMF.pi fun (x : Fin m) => D).toOuterMeasure {S : Fin m → α × Bool | ∃ c ∈ C, (D.toOuterMeasure {p : α × Bool | c p.1 ≠ p.2}).toReal + √(2 * (↑d * Real.log (Real.exp 1 * ↑m / ↑d)) / ↑m) + √(2 * Real.log (2 / δ) / ↑m) < (D.toOuterMeasure {p : α × Bool | A S p.1 ≠ p.2}).toReal}).toReal ≤ δ

Agnostic VC bound for empirical risk minimization: if every finite set shattered by C has at most d points, then for m ≥ d and m > 0, with probability at least 1 - δ over m independent examples from D, an empirical risk minimizer A for C satisfies err_D(A S) ≤ err_D(c) + √(2 d log (e m / d) / m) + √(2 log (2 / δ) / m) for every c ∈ C, an excess error of O(√((d log (m / d) + log (1 / δ)) / m)). This combines PACLearning.IsERM.rademacherComplexity_agnostic_bound with the VC bound on the Rademacher complexity [MohriRostamizadehTalwalkar2018, Corollaries 3.8 and 3.18]. The domain is finite.