Documentation

CslibFrontier.MachineLearning.PACLearning.FiniteClass

Finite concept classes are PAC learnable in the realizable setting #

Let H be a finite concept class and D a probability distribution on α × β realizable by H. A hypothesis whose true error exceeds ε agrees with m i.i.d. examples with probability at most (1 - ε) ^ m. A consistent learner outputs a concept of the version space on almost every sample, so by the union bound its error exceeds ε with probability at most |H| (1 - ε) ^ m. Hence

m ≥ (log |H| + log (1 / δ)) / ε

samples make every consistent learner (in particular every empirical risk minimizer, see IsERM.isConsistent) an (ε, δ)-PAC learner over all distributions realizable by H [ShalevShwartzBenDavid2014, Corollary 2.3]. Learners here are semantic maps from samples to hypotheses; no running-time bound is claimed.

The probability bounds need the misclassification set {p | h p.1 ≠ p.2} of every h ∈ H to be measurable. This holds when every h ∈ H is measurable and equality on β is measurable, see measurableSet_misclassified; for instance when β is Bool.

Main results #

References #

theorem Cslib.MachineLearning.PACLearning.measure_pi_forall_apply_eq_eq_pow_card {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] {ι : Type u_3} [Fintype ι] (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] {h : α → β} (hh : MeasurableSet {p : α × β | h p.1 ≠ p.2}) :
(MeasureTheory.Measure.pi fun (x : ι) => D) {S : ι → α × β | ∀ (i : ι), h (S i).1 = (S i).2} = (1 - error D h) ^ Fintype.card ι

A fixed hypothesis h agrees with i.i.d. examples from D indexed by a finite type ι with probability (1 - error D h) ^ |ι|.

theorem Cslib.MachineLearning.PACLearning.measure_pi_forall_apply_eq_eq_pow {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] {h : α → β} (hh : MeasurableSet {p : α × β | h p.1 ≠ p.2}) (m : ℕ) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : LabeledSample α β m | ∀ (i : Fin m), h (S i).1 = (S i).2} = (1 - error D h) ^ m

A fixed hypothesis h agrees with all m i.i.d. examples drawn from D with probability (1 - error D h) ^ m.

theorem Cslib.MachineLearning.PACLearning.measure_pi_exists_consistent_lt_error_le_card_mul_pow {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] {H : Finset (α → β)} (hH : ∀ h ∈ H, MeasurableSet {p : α × β | h p.1 ≠ p.2}) (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] {m : ℕ} (ε : ENNReal) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : LabeledSample α β m | ∃ h ∈ H, ε < error D h ∧ ∀ (i : Fin m), h (S i).1 = (S i).2} ≤ ↑H.card * (1 - ε) ^ m

Union bound over a finite class. For any distribution D, the probability over m i.i.d. examples that some h ∈ H with true error greater than ε agrees with all of them is at most |H| (1 - ε) ^ m. No learner and no realizability are involved.

theorem Cslib.MachineLearning.PACLearning.IsConsistent.measure_pi_lt_error_le_card_mul_pow {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] {H : Finset (α → β)} (hH : ∀ h ∈ H, MeasurableSet {p : α × β | h p.1 ≠ p.2}) {m : ℕ} {A : Learner α β m} (hA : IsConsistent A ↑H) {D : MeasureTheory.Measure (α × β)} [MeasureTheory.IsProbabilityMeasure D] (hD : IsRealizableBy D ↑H) (ε : ENNReal) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | ε < error D (A S)} ≤ ↑H.card * (1 - ε) ^ m

Union bound for consistent learners of a finite class. If D is realizable by the finite class H and A is consistent with H, then the probability over m i.i.d. examples that the output of A has true error greater than ε is at most |H| (1 - ε) ^ m.

theorem Cslib.MachineLearning.PACLearning.natCast_mul_one_sub_ofReal_pow_le {n m : ℕ} {ε δ : ℝ} (hε : 0 ≤ ε) (hδ : 0 < δ) (hm : Real.log ↑n + Real.log δ⁻¹ ≤ ε * ↑m) :

The Occam sample size. n (1 - ε) ^ m ≤ δ once log n + log (1 / δ) ≤ ε m.

theorem Cslib.MachineLearning.PACLearning.IsConsistent.measure_pi_lt_error_le_of_log_card_add_log_inv_le {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] {H : Finset (α → β)} (hH : ∀ h ∈ H, MeasurableSet {p : α × β | h p.1 ≠ p.2}) {m : ℕ} {A : Learner α β m} (hA : IsConsistent A ↑H) {D : MeasureTheory.Measure (α × β)} [MeasureTheory.IsProbabilityMeasure D] (hD : IsRealizableBy D ↑H) {ε δ : ℝ} (hε : 0 ≤ ε) (hδ : 0 < δ) (hm : Real.log ↑H.card + Real.log δ⁻¹ ≤ ε * ↑m) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | ENNReal.ofReal ε < error D (A S)} ≤ ENNReal.ofReal δ

Occam bound for finite classes [ShalevShwartzBenDavid2014, Corollary 2.3]. If D is realizable by the finite class H, A is consistent with H, and log |H| + log (1 / δ) ≤ ε m, then the output of A on m i.i.d. examples has true error greater than ε with probability at most δ.

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

Finite classes are PAC learnable in the realizable setting [ShalevShwartzBenDavid2014, Corollary 2.3]: a finite class H is (ε, δ)-PAC learnable from m examples over the distributions realizable by H whenever log |H| + log (1 / δ) ≤ ε m. If H is nonempty the learner is any consistent learner, which exists by exists_isConsistent. If H is empty no distribution is realizable, and the hypothesis forces m ≥ 1 because log 0 = 0 < log (1 / δ); any learner that returns the label of its first example works.

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

The realizable sample complexity of a finite class H is at most ⌈(log |H| + log (1 / δ)) / ε⌉ [ShalevShwartzBenDavid2014, Corollary 2.3].