Documentation

CslibFrontier.MachineLearning.PACLearning.AgnosticFiniteClass

Agnostic PAC learning of finite classes #

Every finite class H of hypotheses α → β is agnostically PAC learnable for the 0-1 loss by empirical risk minimization [ShalevShwartzBenDavid2014, Corollary 4.6, stated there for any loss with values in [0, 1]]. Under every distribution D on α × β, realizable or not, an ERM learner on

m ≥ 2 log (2 |H| / δ) / ε²

i.i.d. examples outputs a hypothesis whose error is at most optimalError D H + ε with probability at least 1 - δ. This is the upstream IsPACLearnerFor over the family Set.univ of all distributions: its success criterion is already measured against the optimal error of the class. The proof combines uniform convergence for finite classes with Lemma 4.2 of the source (UniformConvergence.lean).

Each hypothesis needs a measurable misclassification set; measurableSet_misclassified supplies this for measurable hypotheses with Bool labels. The learners are semantic maps: no running time is claimed, and finding an empirical risk minimizer can be computationally hard.

Main results #

References #

theorem Cslib.MachineLearning.PACLearning.IsERM.measure_pi_lt_error_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 : ℕ} {A : Learner α β m} (hA : IsERM A ↑H) {ε : ℝ} (hε : 0 ≤ ε) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | optimalError D ↑H + ENNReal.ofReal ε < error D (A S)} ≤ ↑H.card * ENNReal.ofReal (2 * Real.exp (-↑m * ε ^ 2 / 2))

Agnostic tail bound for ERM on a finite class: under every distribution D, an empirical risk minimizer for H misses optimalError D H + ε with probability at most |H| · 2 exp (-m ε² / 2).

theorem Cslib.MachineLearning.PACLearning.IsERM.measure_pi_lt_error_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 : ℕ} {A : Learner α β m} (hA : IsERM A ↑H) {ε δ : ℝ} (hε : 0 ≤ ε) (hδ : 0 < δ) (hm : 2 * Real.log (2 * ↑H.card / δ) ≤ ε ^ 2 * ↑m) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | optimalError D ↑H + ENNReal.ofReal ε < error D (A S)} ≤ ENNReal.ofReal δ

Finite classes are agnostically PAC learnable by ERM for the 0-1 loss [ShalevShwartzBenDavid2014, Corollary 4.6]: under every distribution D, if m ≥ 2 log (2 |H| / δ) / ε² then an empirical risk minimizer for H misses optimalError D H + ε with probability at most δ.

theorem Cslib.MachineLearning.PACLearning.isPACLearnerFor_univ_of_log_le {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] [Nonempty (α → β)] {H : Finset (α → β)} (hH : ∀ h ∈ H, MeasurableSet {p : α × β | h p.1 ≠ p.2}) {m : ℕ} {ε δ : ↑(Set.Ioo 0 1)} (hm : 2 * Real.log (2 * ↑H.card / ↑↑δ) ≤ ↑↑ε ^ 2 * ↑m) :
IsPACLearnerFor m ε δ (↑H) Set.univ

Agnostic PAC learning of finite classes for the 0-1 loss [ShalevShwartzBenDavid2014, Corollary 4.6]: a finite class H is (ε, δ)-PAC learnable over all distributions from m ≥ 2 log (2 |H| / δ) / ε² examples. If H is nonempty the learner is any empirical risk minimizer. If H is empty the optimal error is ⊤ and any learner works. The instance Nonempty (α → β) is needed in that case: the hypothesis on m then holds at m = 0, and there is no learner from zero examples when α → β is empty.

theorem Cslib.MachineLearning.PACLearning.sampleComplexity_univ_le_of_finite {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] [Nonempty (α → β)] {H : Finset (α → β)} (hH : ∀ h ∈ H, MeasurableSet {p : α × β | h p.1 ≠ p.2}) (ε δ : ↑(Set.Ioo 0 1)) :
sampleComplexity IsPACLearnerFor (↑H) ε δ Set.univ ≤ ⌈2 * Real.log (2 * ↑H.card / ↑↑δ) / ↑↑ε ^ 2⌉₊

The agnostic sample complexity of a finite class H for the 0-1 loss is at most ⌈2 log (2 |H| / δ) / ε²⌉ [ShalevShwartzBenDavid2014, Corollary 4.6].

theorem Cslib.MachineLearning.PACLearning.isPACLearnable_univ_of_finite {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] {H : Finset (α → β)} (hH : ∀ h ∈ H, MeasurableSet {p : α × β | h p.1 ≠ p.2}) :

Every finite class is agnostically PAC learnable for the 0-1 loss [ShalevShwartzBenDavid2014, Corollary 4.6]. No instance Nonempty (α → β) is needed here: for the empty class one example suffices, and the learner returns its label.