Documentation

CslibFrontier.MachineLearning.OnlineLearning.SwapReduction

Black-box external-to-swap regret reduction #

This module formalizes the generic black-box reduction from any external-regret online algorithm (IsOnlineAlgorithm) to a swap-regret online algorithm of [BlumMansour2007AGT, §4.5, Definition 4.14, Theorem 4.15, Corollary 4.16, and Exercise 4.6, pp. 92–94, 101], reusing swap_regret_le_sum_regret from SwapRegret.lean and Matrix.stationaryVec from Stochastic.lean.

While SwapRegret.lean constructs the coupled Hedge instantiation (blumMansourProb) directly, this module constructs the black-box master learner swapMasterProb A for any family A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ of causal online algorithms (IsOnlineAlgorithm (A j)):

Main definitions #

Main results #

References #

Black-box Blum–Mansour master learner #

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.swapMasterProb {ι : Type u_1} [Fintype ι] [DecidableEq ι] (A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ) (ℓ : ℕ → ι → ℝ) :
ℕ → ι → ℝ

Black-box Blum–Mansour master learner [BlumMansour2007AGT, §4.5, pp. 92–93]: combines any family A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ of external-regret copies into a single master distribution sequence via stationary vectors p^t = p^t Q^t.

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.swapMasterLoss {ι : Type u_1} [Fintype ι] [DecidableEq ι] (A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ) (ℓ : ℕ → ι → ℝ) (j : ι) (t : ℕ) (i : ι) :

The scaled loss sequence p^t_j * ℓ^t fed to copy j in swapMasterProb.

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.swapMasterMatrix {ι : Type u_1} [Fintype ι] [DecidableEq ι] (A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) :
Matrix ι ι ℝ

Row-stochastic matrix Q^t whose row j is copy j's distribution on swapMasterLoss.

theorem Cslib.MachineLearning.OnlineLearning.Experts.swapMasterLoss_apply {ι : Type u_1} [Fintype ι] [DecidableEq ι] (A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ) (ℓ : ℕ → ι → ℝ) (j : ι) (t : ℕ) (i : ι) :
swapMasterLoss A ℓ j t i = swapMasterProb A ℓ t j * ℓ t i
theorem Cslib.MachineLearning.OnlineLearning.Experts.swapMasterMatrix_apply {ι : Type u_1} [Fintype ι] [DecidableEq ι] (A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) (j i : ι) :
swapMasterMatrix A ℓ t j i = A j (swapMasterLoss A ℓ j) t i
theorem Cslib.MachineLearning.OnlineLearning.Experts.swapMasterMatrix_mem_rowStochastic {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ} (hA : ∀ (j : ι), IsOnlineAlgorithm (A j)) {ℓ : ℕ → ι → ℝ} {t : ℕ} (hℓ : ∀ s < t, ∀ (i : ι), ℓ s i ∈ Set.Icc 0 1) :

On [0, 1] histories, swapMasterMatrix A ℓ t is row-stochastic.

theorem Cslib.MachineLearning.OnlineLearning.Experts.swapMasterProb_eq_stationaryVec {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ} (hA : ∀ (j : ι), IsOnlineAlgorithm (A j)) {ℓ : ℕ → ι → ℝ} {t : ℕ} (hℓ : ∀ s < t, ∀ (i : ι), ℓ s i ∈ Set.Icc 0 1) :

On [0, 1] histories, swapMasterProb A ℓ t equals stationaryVec (swapMasterMatrix A ℓ t).

theorem Cslib.MachineLearning.OnlineLearning.Experts.swapMasterProb_vecMul {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ} (hA : ∀ (j : ι), IsOnlineAlgorithm (A j)) {ℓ : ℕ → ι → ℝ} {t : ℕ} (hℓ : ∀ s < t, ∀ (i : ι), ℓ s i ∈ Set.Icc 0 1) :

On [0, 1] histories, swapMasterProb A ℓ t is stationary for swapMasterMatrix A ℓ t.

theorem Cslib.MachineLearning.OnlineLearning.Experts.swapMasterLoss_mem_Icc {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ} (hA : ∀ (j : ι), IsOnlineAlgorithm (A j)) {ℓ : ℕ → ι → ℝ} {T : ℕ} (hℓ : ∀ s < T, ∀ (i : ι), ℓ s i ∈ Set.Icc 0 1) {s : ℕ} (hs : s < T) (j i : ι) :
swapMasterLoss A ℓ j s i ∈ Set.Icc 0 1

On [0, 1] histories, the scaled losses swapMasterLoss A ℓ j s i remain in [0, 1].

theorem Cslib.MachineLearning.OnlineLearning.Experts.isOnlineAlgorithm_swapMasterProb {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ} (hA : ∀ (j : ι), IsOnlineAlgorithm (A j)) :

Causality of swapMasterProb: combining any family of causal online algorithms produces a causal online algorithm (IsOnlineAlgorithm).

Theorem 4.15: Black-box external-to-swap regret reduction #

theorem Cslib.MachineLearning.OnlineLearning.Experts.swapMasterProb_swap_regret_le_sum {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {A : ι → (ℕ → ι → ℝ) → ℕ → ι → ℝ} (hA : ∀ (j : ι), IsOnlineAlgorithm (A j)) {ℓ : ℕ → ι → ℝ} {T : ℕ} (hℓ : ∀ s < T, ∀ (i : ι), ℓ s i ∈ Set.Icc 0 1) {R : ι → ℝ} (hR : ∀ (j k : ι), ∑ t ∈ Finset.range T, ∑ i : ι, A j (swapMasterLoss A ℓ j) t i * swapMasterLoss A ℓ j t i ≤ ∑ t ∈ Finset.range T, swapMasterLoss A ℓ j t k + R j) :
modRegret Set.univ (swapMasterProb A ℓ) ℓ T ≤ ∑ j : ι, R j

Black-box Blum–Mansour reduction (per-copy form) [BlumMansour2007AGT, §4.5, Theorem 4.15, p. 93]: if each copy A j is a causal online algorithm achieving external regret at most R j on its realized [0, 1] scaled losses swapMasterLoss A ℓ j, then swapMasterProb A has swap regret at most ∑ j, R j.

theorem Cslib.MachineLearning.OnlineLearning.Experts.swapMasterProb_swap_regret_le_card_mul {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {H : (ℕ → ι → ℝ) → ℕ → ι → ℝ} (hH : IsOnlineAlgorithm H) {T : ℕ} {R : ℝ} (hR : ∀ (c : ℕ → ι → ℝ), (∀ s < T, ∀ (i : ι), c s i ∈ Set.Icc 0 1) → ∀ (k : ι), ∑ t ∈ Finset.range T, ∑ i : ι, H c t i * c t i ≤ ∑ t ∈ Finset.range T, c t k + R) {ℓ : ℕ → ι → ℝ} (hℓ : ∀ s < T, ∀ (i : ι), ℓ s i ∈ Set.Icc 0 1) :
modRegret Set.univ (swapMasterProb (fun (x : ι) => H) ℓ) ℓ T ≤ ↑(Fintype.card ι) * R

Theorem 4.15 (uniform black-box external-to-swap reduction) [BlumMansour2007AGT, §4.5, Definition 4.14 and Theorem 4.15, p. 93]: given any causal online algorithm H achieving external regret at most R over T rounds on all [0, 1] loss sequences, running N copies of H inside swapMasterProb (fun _ => H) yields a causal online algorithm with swap regret at most N * R.

Corollary 4.16 and Exercise 4.6 via Polynomial Weights #

theorem Cslib.MachineLearning.OnlineLearning.Experts.swapMasterMW_swap_regret_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {η : ℝ} (hη : 0 < η) (hη' : η ≤ 1 / 2) {ℓ : ℕ → ι → ℝ} {T : ℕ} (hℓ : ∀ s < T, ∀ (i : ι), ℓ s i ∈ Set.Icc 0 1) :
modRegret Set.univ (swapMasterProb (fun (x : ι) => prob (mwFactor η)) ℓ) ℓ T ≤ η * ↑T + ↑(Fintype.card ι) * Real.log ↑(Fintype.card ι) / η

Polynomial Weights instantiation of Theorem 4.15 / Exercise 4.6 [BlumMansour2007AGT, §4.5, p. 94, and Exercise 4.6, p. 101]: running N Polynomial Weights copies (prob (mwFactor η), 0 < η ≤ 1 / 2) inside swapMasterProb achieves swap regret at most η * T + N * ln N / η on every [0, 1]-valued loss sequence (using ∑ j, ∑ t < T, (p t j * ℓ t (δ j)) ^ 2 ≤ T).

theorem Cslib.MachineLearning.OnlineLearning.Experts.swapMasterMW_swap_regret_le_sqrt {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} (hℓ : ∀ s < T, ∀ (i : ι), ℓ s i ∈ Set.Icc 0 1) :
have η := min (√(↑(Fintype.card ι) * Real.log ↑(Fintype.card ι) / ↑T)) (1 / 2); modRegret Set.univ (swapMasterProb (fun (x : ι) => prob (mwFactor η)) ℓ) ℓ T ≤ 2 * √(↑T * (↑(Fintype.card ι) * Real.log ↑(Fintype.card ι)))

All-horizon 2 √(T N ln N) swap regret via Polynomial Weights [BlumMansour2007AGT, Corollary 4.16, p. 94, and Exercise 4.6, p. 101]: for every nonempty finite action space of size N, every horizon T : ℕ (no T ≥ N ln N floor), and every [0, 1]-valued loss sequence ℓ, running swapMasterProb with capped Polynomial Weights rate η = min √(N * ln N / T) (1 / 2) achieves swap regret at most 2 * √(T * (N * ln N)).