Documentation

CslibFrontier.MachineLearning.PACLearning.SRM

Structural risk minimization #

A class H has uniform convergence rate ε over a family 𝒟 of distributions if, for every D ∈ 𝒟, sample size m > 0 and confidence δ > 0, a sample of m i.i.d. examples is ε m δ-representative for H with probability at least 1 - δ; with ε m δ → 0 as m → ∞ this is the uniform convergence property of [ShalevShwartzBenDavid2014, Definition 4.3], with an explicit rate instead of a sample complexity. Structural risk minimization (SRM) handles a class ⋃ i, H i that is a countable union of classes H i with rates ε i. A weighting w of the indices (positive weights with ∑ w i ≤ 1) splits the confidence δ among the classes, and a union bound gives [ShalevShwartzBenDavid2014, Theorem 7.4]: with probability at least 1 - δ, every h ∈ H i satisfies |L_S(h) - L_D(h)| ≤ ε i m (w i · δ). The SRM rule outputs a hypothesis minimizing the resulting bound L_S(h) + ε i m (w i · δ) over all pairs (i, h) with h ∈ H i. With the same probability its error is at most L_D(h) + 2 ε i m (w i · δ) for every i and h ∈ H i, the excess-risk guarantee behind [ShalevShwartzBenDavid2014, Theorem 7.5].

The bounds hold for arbitrary measurable domain and label spaces, and the union bound needs no measurability of the failure events. The SRM rule here ranges over pairs (i, h) and charges each h the smallest bound of a class containing it; [ShalevShwartzBenDavid2014, Section 7.2] charges h the bound of the first class containing it, which coincides when the bounds grow with i. Learners are semantic maps: no running time is claimed.

Main definitions #

Main results #

References #

Weightings #

A weighting of a type ι: positive real weights with sum at most 1 [ShalevShwartzBenDavid2014, Section 7.2]. SRM spends confidence w i · δ on the i-th class. The weights are positive so that each class receives a nonzero share of the confidence.

  • toFun : ι → ℝ

    The weight of each index.

  • pos (i : ι) : 0 < self.toFun i

    Every weight is positive.

  • summable : Summable self.toFun

    The weights are summable.

  • tsum_le_one : ∑' (i : ι), self.toFun i ≤ 1

    The weights sum to at most 1.

Instances For
    @[instance_reducible]

    The geometric weighting n ↦ 2⁻¹ ^ (n + 1) of ℕ, whose weights sum to 1.

    noncomputable def Cslib.MachineLearning.PACLearning.Weighting.comap {ι : Type u_1} {κ : Type u_2} (w : Weighting κ) {e : ι → κ} (he : Function.Injective e) :

    Pull a weighting back along an injection.

    @[simp]
    theorem Cslib.MachineLearning.PACLearning.Weighting.comap_apply {ι : Type u_1} {κ : Type u_2} (w : Weighting κ) {e : ι → κ} (he : Function.Injective e) (i : ι) :
    (w.comap he).toFun i = w.toFun (e i)

    Every countable type has a weighting.

    Weights tend to 0 along the cofinite filter.

    Uniform convergence rates #

    The class H has uniform convergence rate ε over the family 𝒟: for every probability measure D ∈ 𝒟, sample size m > 0 and confidence δ > 0, m i.i.d. examples from D fail to be ε m δ-representative for H with probability at most δ. On its own this is weak: for the 0-1 loss every rate ε ≥ 1 qualifies. The uniform convergence property of [ShalevShwartzBenDavid2014, Definition 4.3], a finite sample complexity m_H(ε, δ), is a rate with ε m δ → 0 as m → ∞ for every δ > 0, the extra hypothesis of isNonuniformLearnable_iUnion.

    theorem Cslib.MachineLearning.PACLearning.HasUniformConvergenceRate.mono {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] {H : ConceptClass α β} {𝒟 : Set (MeasureTheory.Measure (α × β))} {ε ε' : ℕ → ℝ → ℝ} (hH : HasUniformConvergenceRate H 𝒟 ε) (hε : ∀ (m : ℕ) (δ : ℝ), ε m δ ≤ ε' m δ) :

    A rate can be replaced by a pointwise larger one.

    theorem Cslib.MachineLearning.PACLearning.hasUniformConvergenceRate_finset {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] {H : Finset (α → β)} (hH : ∀ h ∈ H, MeasurableSet {p : α × β | h p.1 ≠ p.2}) :
    HasUniformConvergenceRate (↑H) Set.univ fun (m : ℕ) (δ : ℝ) => √(Real.log (2 * ↑H.card / δ) / (2 * ↑m))

    Uniform convergence for a finite class, rate form [ShalevShwartzBenDavid2014, Corollary 4.6]: a finite class H has uniform convergence rate √(log (2 |H| / δ) / (2 m)) over all distributions.

    theorem Cslib.MachineLearning.PACLearning.hasUniformConvergenceRate_singleton {α : Type u_1} {β : Type u_2} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] {h : α → β} (hh : MeasurableSet {p : α × β | h p.1 ≠ p.2}) :
    HasUniformConvergenceRate {h} Set.univ fun (m : ℕ) (δ : ℝ) => √(Real.log (2 / δ) / (2 * ↑m))

    Hoeffding's inequality as a rate: one hypothesis with a measurable misclassification set has uniform convergence rate √(log (2 / δ) / (2 m)) over all distributions.

    The Hoeffding rate √(log c / (2 m)) tends to 0 as m → ∞.

    The SRM rule #

    def Cslib.MachineLearning.PACLearning.IsSRM {α : Type u_1} {β : Type u_2} {ι : Type u_3} [DecidableEq β] {m : ℕ} (A : Learner α β m) (H : ι → ConceptClass α β) (pen : ι → ℝ) :

    The learner A follows the structural risk minimization rule for the classes H i with penalties pen i [ShalevShwartzBenDavid2014, Section 7.2]: on every sample S, it outputs a hypothesis h of some class H i minimizing L_S(h) + pen i over all pairs (i, h) with h ∈ H i. Choosing pen i = ε i m (w i · δ) makes L_S(h) + pen i the SRM bound.

    theorem Cslib.MachineLearning.PACLearning.exists_isSRM {α : Type u_1} {β : Type u_2} {ι : Type u_3} [DecidableEq β] {m : ℕ} {H : ι → ConceptClass α β} (hne : ∃ (i : ι), Set.Nonempty (H i)) {pen : ι → ℝ} (hpen : Filter.Tendsto pen Filter.cofinite Filter.atTop) :
    ∃ (A : Learner α β m), IsSRM A H pen

    Existence of an SRM learner. If some class is nonempty and the penalties tend to infinity along the cofinite filter, then every sample admits a minimizer of L_S(h) + pen i, so an SRM learner exists. Only finitely many classes have penalty below any bound, and on each of them the empirical miscount takes finitely many values.

    The SRM bound #

    theorem Cslib.MachineLearning.PACLearning.Weighting.measure_pi_exists_not_isRepresentative_le {α : Type u_1} {β : Type u_2} {ι : Type u_3} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] [Countable ι] {H : ι → ConceptClass α β} {𝒟 : Set (MeasureTheory.Measure (α × β))} {ε : ι → ℕ → ℝ → ℝ} (hH : ∀ (i : ι), HasUniformConvergenceRate (H i) 𝒟 (ε i)) (w : Weighting ι) (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] (hD : D ∈ 𝒟) {m : ℕ} (hm : 0 < m) {δ : ℝ} (hδ : 0 < δ) :
    (MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | ∃ (i : ι), ¬IsRepresentative D (H i) (ε i m (w.toFun i * δ)) S} ≤ ENNReal.ofReal δ

    The SRM bound [ShalevShwartzBenDavid2014, Theorem 7.4], representativeness form: if each class H i has uniform convergence rate ε i over 𝒟 and w is a weighting of the countable index type, then for every D ∈ 𝒟, m > 0 and δ > 0, with probability at least 1 - δ the sample is ε i m (w i · δ)-representative for every H i simultaneously.

    theorem Cslib.MachineLearning.PACLearning.Weighting.measure_pi_exists_lt_error_le {α : Type u_1} {β : Type u_2} {ι : Type u_3} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] [Countable ι] {H : ι → ConceptClass α β} {𝒟 : Set (MeasureTheory.Measure (α × β))} {ε : ι → ℕ → ℝ → ℝ} (hH : ∀ (i : ι), HasUniformConvergenceRate (H i) 𝒟 (ε i)) (w : Weighting ι) (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] (hD : D ∈ 𝒟) {m : ℕ} (hm : 0 < m) {δ : ℝ} (hδ : 0 < δ) :
    (MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | ∃ (i : ι), ∃ h ∈ H i, ↑(empiricalMiscount h S) / ↑m + ε i m (w.toFun i * δ) < (error D h).toReal} ≤ ENNReal.ofReal δ

    The SRM bound [ShalevShwartzBenDavid2014, Theorem 7.4]: with probability at least 1 - δ, every h ∈ H i has L_D(h) ≤ L_S(h) + ε i m (w i · δ).

    theorem Cslib.MachineLearning.PACLearning.IsSRM.measure_pi_exists_lt_error_le {α : Type u_1} {β : Type u_2} {ι : Type u_3} [MeasurableSpace α] [MeasurableSpace β] [DecidableEq β] [Countable ι] {H : ι → ConceptClass α β} {𝒟 : Set (MeasureTheory.Measure (α × β))} {ε : ι → ℕ → ℝ → ℝ} (hH : ∀ (i : ι), HasUniformConvergenceRate (H i) 𝒟 (ε i)) (w : Weighting ι) {m : ℕ} (hm : 0 < m) {δ : ℝ} (hδ : 0 < δ) {pen : ι → ℝ} (hpen : ∀ (i : ι), ε i m (w.toFun i * δ) ≤ pen i) {A : Learner α β m} (hA : IsSRM A H pen) (D : MeasureTheory.Measure (α × β)) [MeasureTheory.IsProbabilityMeasure D] (hD : D ∈ 𝒟) :
    (MeasureTheory.Measure.pi fun (x : Fin m) => D) {S : Fin m → α × β | ∃ (i : ι), ∃ h ∈ H i, (error D h).toReal + 2 * pen i < (error D (A S)).toReal} ≤ ENNReal.ofReal δ

    Excess risk of SRM [ShalevShwartzBenDavid2014, Theorem 7.5, proof]: an SRM learner whose penalties dominate the rates ε i m (w i · δ) satisfies, with probability at least 1 - δ, L_D(A S) ≤ L_D(h) + 2 pen i for every i and every h ∈ H i.