Documentation

CslibFrontier.MachineLearning.OnlineLearning.BernsteinOnlineToBatch

Variance-sensitive Bernstein online-to-batch conversion #

Refines the Azuma–Hoeffding high-probability online-to-batch conversion in CslibFrontier.MachineLearning.OnlineLearning.HighProbabilityOnlineToBatch by replacing worst-case sub-Gaussian step widths with the product-filtration Bernstein bound (ProbabilityTheory.measure_sum_gt_sqrt_add_le_pi):

Run an online learner on an i.i.d. sample S = (z₀, …, z_{T-1}) from D. In round t the learner commits to a function f t S : Z → ℝ depending only on z₀, …, z_{t-1} with values in [a, b] and conditional variance ∫ z, (f t S z - ∫ z', f t S z' ∂D)² ∂D ≤ s2 t. With probability at least 1 - δ,

(1 / T) ∑ t, ∫ f t S dD ≤ (1 / T) ∑ t, f t S (S t) + (1 / T) √(2 (∑ t, s2 t) ln (1 / δ)) + 2 (b - a) ln (1 / δ) / (3 T)

(measureReal_average_integral_gt_le_bernstein). Under uniform variance bound s2 across rounds, the leading deviation term scales with √(2 s2 ln (1 / δ) / T) instead of (b - a) √(ln (1 / δ) / (2 T)), and vanishes completely (2 (b - a) ln (1 / δ) / (3 T)) in the zero-variance regime s2 = 0 ([CesaBianchiConconiGentile2004, Section III]).

Main results #

References #

theorem Cslib.MachineLearning.OnlineLearning.measureReal_sum_integral_gt_le_bernstein {Z : Type u_1} [MeasurableSpace Z] {D : MeasureTheory.Measure Z} [MeasureTheory.IsProbabilityMeasure D] {T : ℕ} {f : Fin T → (Fin T → Z) → Z → ℝ} (hf : ∀ (t : Fin T), Measurable (Function.uncurry (f t))) (hfresh : ∀ (t s : Fin T), t ≤ s → ∀ (S : Fin T → Z) (z : Z), f t (Function.update S s z) = f t S) {a b : ℝ} (hab_le : a ≤ b) (hab : ∀ (t : Fin T) (S : Fin T → Z) (z : Z), f t S z ∈ Set.Icc a b) {s2 : Fin T → ℝ} (hσ : ∀ (t : Fin T), 0 ≤ s2 t) (hvar : ∀ (t : Fin T) (S : Fin T → Z), ∫ (z : Z), (f t S z - ∫ (z' : Z), f t S z' ∂D) ^ 2 ∂D ≤ s2 t) {δ : ℝ} (hδ : 0 < δ) (hδ1 : δ ≤ 1) :
have L := Real.log (1 / δ); (MeasureTheory.Measure.pi fun (x : Fin T) => D).real {S : Fin T → Z | ∑ t : Fin T, f t S (S t) + √((2 * ∑ t : Fin T, s2 t) * L) + 2 * (b - a) * L / 3 < ∑ t : Fin T, ∫ (z : Z), f t S z ∂D} ≤ δ

Bernstein online-to-batch conversion, sum form: if f t S depends only on examples before round t, takes values in [a, b] (a ≤ b), and has conditional variance at most s2 t ≥ 0 under D, then with probability at least 1 - δ (δ ∈ (0, 1]), ∑ t, ∫ f t S dD ≤ ∑ t, f t S (S t) + √(2 (∑ t, s2 t) ln (1 / δ)) + 2 (b - a) ln (1 / δ) / 3.

theorem Cslib.MachineLearning.OnlineLearning.measureReal_average_integral_gt_le_bernstein {Z : Type u_1} [MeasurableSpace Z] {D : MeasureTheory.Measure Z} [MeasureTheory.IsProbabilityMeasure D] {T : ℕ} {f : Fin T → (Fin T → Z) → Z → ℝ} (hf : ∀ (t : Fin T), Measurable (Function.uncurry (f t))) (hfresh : ∀ (t s : Fin T), t ≤ s → ∀ (S : Fin T → Z) (z : Z), f t (Function.update S s z) = f t S) {a b : ℝ} (hab : ∀ (t : Fin T) (S : Fin T → Z) (z : Z), f t S z ∈ Set.Icc a b) {s2 : Fin T → ℝ} (hσ : ∀ (t : Fin T), 0 ≤ s2 t) (hvar : ∀ (t : Fin T) (S : Fin T → Z), ∫ (z : Z), (f t S z - ∫ (z' : Z), f t S z' ∂D) ^ 2 ∂D ≤ s2 t) {δ : ℝ} (hδ : 0 < δ) (hδ1 : δ ≤ 1) :
have L := Real.log (1 / δ); (MeasureTheory.Measure.pi fun (x : Fin T) => D).real {S : Fin T → Z | (↑T)⁻¹ * ∑ t : Fin T, f t S (S t) + (↑T)⁻¹ * √((2 * ∑ t : Fin T, s2 t) * L) + 2 * (b - a) * L / (3 * ↑T) < (↑T)⁻¹ * ∑ t : Fin T, ∫ (z : Z), f t S z ∂D} ≤ δ

Bernstein online-to-batch conversion, average form: if f t S depends only on examples before round t, takes values in [a, b], and has conditional variance at most s2 t ≥ 0, then with probability at least 1 - δ (δ ∈ (0, 1]), (1 / T) ∑ t, ∫ f t S dD ≤ (1 / T) ∑ t, f t S (S t) + (1 / T) √(2 (∑ t, s2 t) ln (1 / δ)) + 2 (b - a) ln (1 / δ) / (3 T).

theorem Cslib.MachineLearning.OnlineLearning.measureReal_average_trueRisk_gt_le_bernstein {Z : Type u_1} [MeasurableSpace Z] {D : MeasureTheory.Measure Z} [MeasureTheory.IsProbabilityMeasure D] {T : ℕ} {W : Type u_2} [MeasurableSpace W] {ℓ : W → Z → ℝ} (hℓ : Measurable (Function.uncurry ℓ)) {w : Fin T → (Fin T → Z) → W} (hwm : ∀ (t : Fin T), Measurable (w t)) (hfresh : ∀ (t s : Fin T), t ≤ s → ∀ (S : Fin T → Z) (z : Z), w t (Function.update S s z) = w t S) {a b s2 : ℝ} (hab : ∀ (t : Fin T) (S : Fin T → Z) (z : Z), ℓ (w t S) z ∈ Set.Icc a b) (hσ : 0 ≤ s2) (hvar : ∀ (t : Fin T) (S : Fin T → Z), ∫ (z : Z), (ℓ (w t S) z - trueRisk ℓ D (w t S)) ^ 2 ∂D ≤ s2) {δ : ℝ} (hδ : 0 < δ) (hδ1 : δ ≤ 1) :
have L := Real.log (1 / δ); (MeasureTheory.Measure.pi fun (x : Fin T) => D).real {S : Fin T → Z | (↑T)⁻¹ * ∑ t : Fin T, ℓ (w t S) (S t) + √(2 * s2 * L / ↑T) + 2 * (b - a) * L / (3 * ↑T) < (↑T)⁻¹ * ∑ t : Fin T, trueRisk ℓ D (w t S)} ≤ δ

Bernstein online-to-batch conversion for the iterates of an online learner: if w t S depends only on examples before round t, ℓ (w t S) z ∈ [a, b], and the conditional variance of ℓ (w t S) under D is at most s2 ≥ 0, then with probability at least 1 - δ (δ ∈ (0, 1]), (1 / T) ∑ t, L_D (w t S) ≤ (1 / T) ∑ t, ℓ (w t S) (S t) + √(2 s2 ln (1 / δ) / T) + 2 (b - a) ln (1 / δ) / (3 T).

theorem Cslib.MachineLearning.OnlineLearning.measureReal_trueRisk_average_gt_le_bernstein {Z : Type u_1} [MeasurableSpace Z] {D : MeasureTheory.Measure Z} [MeasureTheory.IsProbabilityMeasure D] {T : ℕ} (hT : 0 < T) {E : Type u_2} [AddCommGroup E] [Module ℝ E] [MeasurableSpace E] {K : Set E} (hK : Convex ℝ K) {ℓ : E → Z → ℝ} (hℓ : Measurable (Function.uncurry ℓ)) (hconv : ∀ (z : Z), ConvexOn ℝ K fun (w : E) => ℓ w z) {u : E} (hui : MeasureTheory.Integrable (ℓ u) D) {c s2 : ℝ} (hc : ∀ w ∈ K, ∀ (z : Z), |ℓ w z - ℓ u z| ≤ c) (hσ : 0 ≤ s2) {w : Fin T → (Fin T → Z) → E} (hwK : ∀ (t : Fin T) (S : Fin T → Z), w t S ∈ K) (hwm : ∀ (t : Fin T), Measurable (w t)) (hfresh : ∀ (t s : Fin T), t ≤ s → ∀ (S : Fin T → Z) (z : Z), w t (Function.update S s z) = w t S) (hvar : ∀ (t : Fin T) (S : Fin T → Z), ∫ (z : Z), (ℓ (w t S) z - ℓ u z - ∫ (z' : Z), ℓ (w t S) z' - ℓ u z' ∂D) ^ 2 ∂D ≤ s2) {R : ℝ} (hR : ∀ (S : Fin T → Z), ∑ t : Fin T, (ℓ (w t S) (S t) - ℓ u (S t)) ≤ R) {δ : ℝ} (hδ : 0 < δ) (hδ1 : δ ≤ 1) :
have L := Real.log (1 / δ); (MeasureTheory.Measure.pi fun (x : Fin T) => D).real {S : Fin T → Z | trueRisk ℓ D u + R / ↑T + √(2 * s2 * L / ↑T) + 4 * c * L / (3 * ↑T) < trueRisk ℓ D ((↑T)⁻¹ • ∑ t : Fin T, w t S)} ≤ δ

Bernstein online-to-batch conversion for convex losses: let ℓ · z be convex on a convex set K, u ∈ K with ℓ u integrable, |ℓ w z - ℓ u z| ≤ c on K, and let the excess loss z ↦ ℓ (w t S) z - ℓ u z have conditional variance at most s2 ≥ 0. If w t S ∈ K depends only on examples before round t and has cumulative online regret at most R, then for T > 0 and δ ∈ (0, 1], with probability at least 1 - δ, the average iterate has true risk at most L_D u + R / T + √(2 s2 ln (1 / δ) / T) + 4 c ln (1 / δ) / (3 T).