Documentation

CslibFrontier.MachineLearning.PACLearning.UniformConvergence

Uniform convergence of empirical errors #

A labeled sample is ε-representative for a class C under a distribution D on α × β if the empirical error of every hypothesis of C on the sample is within ε of its true error [ShalevShwartzBenDavid2014, Definition 4.1]. For a single hypothesis, Hoeffding's inequality bounds the probability that m i.i.d. examples misestimate its error by ε by 2 exp (-2 m ε²) [Hoe63]. A union bound gives uniform convergence for a finite class [ShalevShwartzBenDavid2014, Section 4.2]. On an ε / 2-representative sample every empirical risk minimizer is within ε of the best error in the class [ShalevShwartzBenDavid2014, Lemma 4.2]. This is the agnostic route to PAC learning: no concept of the class needs to fit the distribution.

The domain and label spaces are arbitrary measurable spaces. Each hypothesis needs a measurable misclassification set; measurableSet_misclassified supplies this for measurable hypotheses with Bool labels. Hoeffding's inequality is the library's finite-PMF form for [0, 1] scores (Cslib.Probability.PMF.pi_sum_abs_sub_mean_ge_card_mul), applied to the Bernoulli indicator of a measurable event; the empirical error of a hypothesis is the relative frequency of its misclassification set. Uniform convergence for infinite classes of finite VC dimension is in VCUniformConvergence.lean.

Main definitions #

Main results #

References #

def Cslib.MachineLearning.PACLearning.IsRepresentative {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] (D : MeasureTheory.Measure (α × β)) (C : ConceptClass α β) (ε : ℝ) {m : ℕ} (S : LabeledSample α β m) :

A labeled sample S is ε-representative for the class C under D if the empirical error empiricalMiscount h S / m of every h ∈ C is within ε of its true error [ShalevShwartzBenDavid2014, Definition 4.1].

theorem Cslib.MachineLearning.PACLearning.measure_pi_le_abs_card_filter_div_sub_measure {Z : Type u_3} [MeasurableSpace Z] (μ : MeasureTheory.Measure Z) [MeasureTheory.IsProbabilityMeasure μ] {g : Z → Bool} (hg : Measurable g) (m : ℕ) {ε : ℝ} (hε : 0 ≤ ε) :
(MeasureTheory.Measure.pi fun (x : Fin m) => μ) {S : Fin m → Z | ε ≤ |↑{i : Fin m | g (S i) = true}.card / ↑m - (μ {z : Z | g z = true}).toReal|} ≤ ENNReal.ofReal (2 * Real.exp (-2 * ↑m * ε ^ 2))

Hoeffding's inequality for a relative frequency [Hoe63]: under m i.i.d. samples from μ, the fraction of sample points where a measurable g : Z → Bool is true differs from μ {g = true} by at least ε with probability at most 2 exp (-2 m ε²).

theorem Cslib.MachineLearning.PACLearning.measure_pi_le_abs_empiricalMiscount_div_sub_error {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] {h : α → β} (hh : MeasurableSet {p : α × β | h p.1 ≠ p.2}) (m : ℕ) {ε : ℝ} (hε : 0 ≤ ε) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | ε ≤ |↑(empiricalMiscount h S) / ↑m - (error D h).toReal|} ≤ ENNReal.ofReal (2 * Real.exp (-2 * ↑m * ε ^ 2))

Hoeffding's inequality for the empirical error of one hypothesis [Hoe63]: under m i.i.d. examples from D, the empirical error of h differs from error D h by at least ε with probability at most 2 exp (-2 m ε²). The domain is an arbitrary measurable space; only the misclassification set of h must be measurable.

theorem Cslib.MachineLearning.PACLearning.measure_pi_not_isRepresentative_le {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] {H : Finset (α → β)} (hH : ∀ h ∈ H, MeasurableSet {p : α × β | h p.1 ≠ p.2}) (m : ℕ) {ε : ℝ} (hε : 0 ≤ ε) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | ¬IsRepresentative D (↑H) ε S} ≤ ↑H.card * ENNReal.ofReal (2 * Real.exp (-2 * ↑m * ε ^ 2))

Uniform convergence for a finite class [ShalevShwartzBenDavid2014, Section 4.2]: m i.i.d. examples fail to be ε-representative for a finite class H with probability at most |H| · 2 exp (-2 m ε²).

theorem Cslib.MachineLearning.PACLearning.measure_pi_not_isRepresentative_le_of_log_le {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] {H : Finset (α → β)} (hH : ∀ h ∈ H, MeasurableSet {p : α × β | h p.1 ≠ p.2}) {m : ℕ} {ε δ : ℝ} (hε : 0 ≤ ε) (hδ : 0 < δ) (hm : Real.log (2 * ↑H.card / δ) ≤ 2 * ↑m * ε ^ 2) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | ¬IsRepresentative D (↑H) ε S} ≤ ENNReal.ofReal δ

Uniform convergence for a finite class, sample-size form: m i.i.d. examples fail to be ε-representative for a finite class H with probability at most δ once log (2 |H| / δ) ≤ 2 m ε².

ERM on a representative sample [ShalevShwartzBenDavid2014, Lemma 4.2]: on an ε / 2-representative sample for C, every empirical risk minimizer for C outputs a hypothesis whose error is at most optimalError D C + ε. The class need not be finite.

theorem Cslib.MachineLearning.PACLearning.IsRepresentative.mono {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] {D : MeasureTheory.Measure (α × β)} {C : ConceptClass α β} {ε ε' : ℝ} {m : ℕ} {S : LabeledSample α β m} (hS : IsRepresentative D C ε S) (hε : ε ≤ ε') :

An ε-representative sample is ε'-representative for every ε' ≥ ε.