Documentation

CslibFrontier.MachineLearning.PACLearning.AgnosticVCSharp

The sharp agnostic sample size for classes of finite VC dimension #

If every finite set shattered by a Boolean class G on a countable domain has at most d points, then for m ≥ 16384 d / ε² i.i.d. samples from μ, the relative frequency of some {g = true}, g ∈ G, deviates from its probability by at least ε with probability at most 4 exp (-m ε² / 32). Unlike measure_pi_exists_le_abs_card_filter_div_sub_measure_le, the bound has no growth-function factor, so the sample size

chainingSampleSize d ε δ = (16384 d + 32 log (4 / δ)) / ε²

that brings it below δ has no factor log (1 / ε). For the loss class of a binary concept class C this gives uniform convergence, agnostic PAC learning by empirical risk minimization from chainingSampleSize d (ε / 2) δ examples, and the agnostic sample-complexity bound O ((d + log (1 / δ)) / ε²) of [ShalevShwartzBenDavid2014, Theorem 6.8]. Shalev-Shwartz and Ben-David prove only the weaker O ((d log (d / ε) + log (1 / δ)) / ε²) (Section 28.1) and do not apply their chaining lemma (Lemma 27.4) to the sharp form; the route here is that of [Vershynin2018, Section 8.3], with explicit, unoptimized constants.

The proof is double-sample symmetrization with a different swap step.

Through the loss class, whose shattered sets are no larger than those of C (card_le_of_setShatters_lossClass in VCUpperBound.lean), this gives the classification results. The domain is countable with measurable singletons, as in VCUniformConvergence.lean; uncountable domains need a measurability hypothesis on the class. The constants are far from optimal: at ε = δ = 1 / 10 and d = 1 the explicit size is about 6.6 · 10⁶, against 97600 from uniformConvergenceSampleSize. The improvement is in the rate, which wins only as ε → 0.

Main definitions #

Main results #

References #

Counting swaps by chaining #

theorem Cslib.MachineLearning.PACLearning.card_filter_swapSamples_exists_le_abs_le {Z : Type u_1} {G : ConceptClass Z Bool} {d : ℕ} (hG : ∀ (W : Finset Z), SetShatters G ↑W → W.card ≤ d) {m : ℕ} {ε : ℝ} (hε : 0 ≤ ε) (hm : 16384 * ↑d ≤ ↑m * ε ^ 2) (z : (Fin m → Z) × (Fin m → Z)) :
↑{σ : Fin m → Bool | ∃ g ∈ G, ↑m * ε / 2 ≤ |↑{i : Fin m | g ((swapSamples σ z).1 i) = true}.card - ↑{i : Fin m | g ((swapSamples σ z).2 i) = true}.card|}.card ≤ 2 ^ m * (2 * Real.exp (-(↑m * ε ^ 2 / 32)))

Counting bad swaps by chaining: if every finite set shattered by G has at most d points and 16384 d ≤ m ε², then for every double sample z, at most a 2 exp (-m ε² / 32) fraction of the swaps σ give some g ∈ G counts on the two swapped samples that differ by at least m ε / 2.

Uniform convergence #

theorem Cslib.MachineLearning.PACLearning.measure_pi_exists_le_abs_card_filter_div_sub_measure_le_exp {Z : Type u_1} [MeasurableSpace Z] [MeasurableSingletonClass Z] [Countable Z] (μ : MeasureTheory.Measure Z) [MeasureTheory.IsProbabilityMeasure μ] {G : ConceptClass Z Bool} {d : ℕ} (hG : ∀ (W : Finset Z), SetShatters G ↑W → W.card ≤ d) {m : ℕ} {ε : ℝ} (hε : 0 ≤ ε) (hm : 16384 * ↑d ≤ ↑m * ε ^ 2) :
(MeasureTheory.Measure.pi fun (x : Fin m) => μ) {S : Fin m → Z | ∃ g ∈ G, ε ≤ |↑{i : Fin m | g (S i) = true}.card / ↑m - (μ {z : Z | g z = true}).toReal|} ≤ ENNReal.ofReal (4 * Real.exp (-(↑m * ε ^ 2 / 32)))

Uniform convergence without a growth-function factor on a countable domain [Vershynin2018, Section 8.3]: if every finite set shattered by G has at most d points and 16384 d ≤ m ε², then under m i.i.d. samples from μ, the probability that the relative frequency of {g = true} deviates from μ {g = true} by at least ε for some g ∈ G is at most 4 exp (-m ε² / 32).

The sample size (16384 d + 32 log (4 / δ)) / ε² of the chaining bound.

theorem Cslib.MachineLearning.PACLearning.measure_pi_not_isRepresentative_le_exp_of_lossClass {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSingletonClass α] [Countable α] [MeasurableSpace β] [MeasurableSingletonClass β] [Countable β] [DecidableEq β] (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] {C : ConceptClass α β} {d : ℕ} (hloss : ∀ (W : Finset (α × β)), SetShatters (lossClass C) ↑W → W.card ≤ d) {m : ℕ} {ε : ℝ} (hε : 0 ≤ ε) (hm : 16384 * ↑d ≤ ↑m * ε ^ 2) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | ¬IsRepresentative D C ε S} ≤ ENNReal.ofReal (4 * Real.exp (-(↑m * ε ^ 2 / 32)))

Uniform convergence without a growth-function factor for any concept class C on a countable domain and label space whose Boolean loss class shatters no finite set of more than d labeled points: once 16384 d ≤ m ε², m i.i.d. examples fail to be ε-representative for C with probability at most 4 exp (-m ε² / 32).

theorem Cslib.MachineLearning.PACLearning.measure_pi_not_isRepresentative_le_of_chainingSampleSize_le_of_lossClass {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSingletonClass α] [Countable α] [MeasurableSpace β] [MeasurableSingletonClass β] [Countable β] [DecidableEq β] (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] {C : ConceptClass α β} {d : ℕ} (hloss : ∀ (W : Finset (α × β)), SetShatters (lossClass C) ↑W → W.card ≤ d) {m : ℕ} {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) (hm : chainingSampleSize d ε δ ≤ ↑m) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | ¬IsRepresentative D C ε S} ≤ ENNReal.ofReal δ

Uniform convergence with the chaining sample size for any concept class C on a countable domain and label space whose Boolean loss class shatters no finite set of more than d labeled points: once m ≥ chainingSampleSize d ε δ, m i.i.d. examples fail to be ε-representative for C with probability at most δ.

theorem Cslib.MachineLearning.PACLearning.measure_pi_not_isRepresentative_le_exp {α : Type u_1} [MeasurableSpace α] [MeasurableSingletonClass α] [Countable α] (D : MeasureTheory.Measure (α × Bool)) [MeasureTheory.IsProbabilityMeasure D] {C : ConceptClass α Bool} {d : ℕ} (hC : ∀ (W : Finset α), SetShatters C ↑W → W.card ≤ d) {m : ℕ} {ε : ℝ} (hε : 0 ≤ ε) (hm : 16384 * ↑d ≤ ↑m * ε ^ 2) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × Bool | ¬IsRepresentative D C ε S} ≤ ENNReal.ofReal (4 * Real.exp (-(↑m * ε ^ 2 / 32)))

Uniform convergence without a growth-function factor for a binary concept class on a countable domain: if every finite set shattered by C has at most d points and 16384 d ≤ m ε², then m i.i.d. examples fail to be ε-representative for C with probability at most 4 exp (-m ε² / 32).

theorem Cslib.MachineLearning.PACLearning.measure_pi_not_isRepresentative_le_of_chainingSampleSize_le {α : Type u_1} [MeasurableSpace α] [MeasurableSingletonClass α] [Countable α] (D : MeasureTheory.Measure (α × Bool)) [MeasureTheory.IsProbabilityMeasure D] {C : ConceptClass α Bool} {d : ℕ} (hC : ∀ (W : Finset α), SetShatters C ↑W → W.card ≤ d) {m : ℕ} {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) (hm : chainingSampleSize d ε δ ≤ ↑m) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × Bool | ¬IsRepresentative D C ε S} ≤ ENNReal.ofReal δ

Uniform convergence with the chaining sample size on a countable domain: if every finite set shattered by C has at most d points and m ≥ (16384 d + 32 log (4 / δ)) / ε², then m i.i.d. examples fail to be ε-representative for C with probability at most δ.

theorem Cslib.MachineLearning.PACLearning.IsERM.measure_pi_lt_error_le_exp {α : Type u_1} [MeasurableSpace α] [MeasurableSingletonClass α] [Countable α] (D : MeasureTheory.Measure (α × Bool)) [MeasureTheory.IsProbabilityMeasure D] {C : ConceptClass α Bool} {d : ℕ} (hC : ∀ (W : Finset α), SetShatters C ↑W → W.card ≤ d) {m : ℕ} {A : Learner α Bool m} (hA : IsERM A C) {ε : ℝ} (hε : 0 ≤ ε) (hm : 65536 * ↑d ≤ ↑m * ε ^ 2) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × Bool | optimalError D C + ENNReal.ofReal ε < error D (A S)} ≤ ENNReal.ofReal (4 * Real.exp (-(↑m * ε ^ 2 / 128)))

Agnostic tail bound for ERM without a growth-function factor on a countable domain: if every finite set shattered by C has at most d points and 65536 d ≤ m ε², then under every distribution an empirical risk minimizer for C misses optimalError D C + ε with probability at most 4 exp (-m ε² / 128).

theorem Cslib.MachineLearning.PACLearning.IsERM.measure_pi_lt_error_le_of_chainingSampleSize_le {α : Type u_1} [MeasurableSpace α] [MeasurableSingletonClass α] [Countable α] (D : MeasureTheory.Measure (α × Bool)) [MeasureTheory.IsProbabilityMeasure D] {C : ConceptClass α Bool} {d : ℕ} (hC : ∀ (W : Finset α), SetShatters C ↑W → W.card ≤ d) {m : ℕ} {A : Learner α Bool m} (hA : IsERM A C) {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) (hm : chainingSampleSize d (ε / 2) δ ≤ ↑m) :
(MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × Bool | optimalError D C + ENNReal.ofReal ε < error D (A S)} ≤ ENNReal.ofReal δ

Agnostic learning by ERM with the chaining sample size on a countable domain: if every finite set shattered by C has at most d points and m ≥ chainingSampleSize d (ε / 2) δ = (65536 d + 128 log (4 / δ)) / ε², then under every distribution an empirical risk minimizer for C misses optimalError D C + ε with probability at most δ.

theorem Cslib.MachineLearning.PACLearning.isPACLearnerFor_univ_of_chainingSampleSize_le {α : Type u_1} [MeasurableSpace α] [MeasurableSingletonClass α] [Countable α] {C : ConceptClass α Bool} {d : ℕ} (hC : ∀ (W : Finset α), SetShatters C ↑W → W.card ≤ d) {m : ℕ} {ε δ : ↑(Set.Ioo 0 1)} (hm : chainingSampleSize d (↑↑ε / 2) ↑↑δ ≤ ↑m) :

The sharp agnostic sample size [ShalevShwartzBenDavid2014, Theorem 6.8] on a countable domain: a class whose shattered finite sets have at most d points is (ε, δ)-PAC learnable over all distributions from m ≥ chainingSampleSize d (ε / 2) δ = O ((d + log (1 / δ)) / ε²) examples. If C is nonempty the learner is any empirical risk minimizer. If C is empty the optimal error is ⊤ and any learner works.

The agnostic sample complexity of a class of finite VC dimension on a countable domain is at most ⌈chainingSampleSize (vcDim C) (ε / 2) δ⌉ = O ((vcDim C + log (1 / δ)) / ε²) [ShalevShwartzBenDavid2014, Theorem 6.8].