Documentation

CslibFrontier.MachineLearning.OnlineLearning.Greedy

Greedy and randomized greedy algorithms for learning with experts #

This module formalizes the warmup external-regret algorithms of [BlumMansour2007AGT, §4.3.1, pp. 83–84] in the experts setting (Cslib.MachineLearning.OnlineLearning.Experts):

Main definitions #

Main results #

References #

Minimum cumulative loss and leaders #

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.minCumLoss {ι : Type u_1} (ℓ : ℕ → ι → ℝ) (t : ℕ) :

Minimum cumulative loss ⨅ i, ∑ s ∈ range t, ℓ s i before round t (L_min^t).

@[simp]
theorem Cslib.MachineLearning.OnlineLearning.Experts.minCumLoss_le {ι : Type u_1} [Finite ι] (ℓ : ℕ → ι → ℝ) (t : ℕ) (i : ι) :
minCumLoss ℓ t ≤ ∑ s ∈ Finset.range t, ℓ s i
theorem Cslib.MachineLearning.OnlineLearning.Experts.le_minCumLoss_iff {ι : Type u_1} [Finite ι] [Nonempty ι] {ℓ : ℕ → ι → ℝ} {t : ℕ} {c : ℝ} :
c ≤ minCumLoss ℓ t ↔ ∀ (i : ι), c ≤ ∑ s ∈ Finset.range t, ℓ s i
theorem Cslib.MachineLearning.OnlineLearning.Experts.exists_sum_eq_minCumLoss {ι : Type u_1} [Finite ι] [Nonempty ι] (ℓ : ℕ → ι → ℝ) (t : ℕ) :
∃ (i : ι), ∑ s ∈ Finset.range t, ℓ s i = minCumLoss ℓ t
theorem Cslib.MachineLearning.OnlineLearning.Experts.minCumLoss_nonneg {ι : Type u_1} {ℓ : ℕ → ι → ℝ} {t : ℕ} (hℓ : ∀ s < t, ∀ (i : ι), 0 ≤ ℓ s i) :
0 ≤ minCumLoss ℓ t
theorem Cslib.MachineLearning.OnlineLearning.Experts.minCumLoss_mono_succ {ι : Type u_1} [Finite ι] {ℓ : ℕ → ι → ℝ} {t : ℕ} (hℓ : ∀ (i : ι), 0 ≤ ℓ t i) :
minCumLoss ℓ t ≤ minCumLoss ℓ (t + 1)
theorem Cslib.MachineLearning.OnlineLearning.Experts.minCumLoss_congr {ι : Type u_1} {ℓ ℓ' : ℕ → ι → ℝ} {t : ℕ} (h : ∀ s < t, ℓ s = ℓ' s) :
minCumLoss ℓ t = minCumLoss ℓ' t
noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.leaders {ι : Type u_1} [Fintype ι] (ℓ : ℕ → ι → ℝ) (t : ℕ) :

The set S^t of current minimum-cumulative-loss leaders before round t.

theorem Cslib.MachineLearning.OnlineLearning.Experts.mem_leaders {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {t : ℕ} {i : ι} :
i ∈ leaders ℓ t ↔ ∑ s ∈ Finset.range t, ℓ s i = minCumLoss ℓ t
theorem Cslib.MachineLearning.OnlineLearning.Experts.leaders_congr {ι : Type u_1} [Fintype ι] {ℓ ℓ' : ℕ → ι → ℝ} {t : ℕ} (h : ∀ s < t, ℓ s = ℓ' s) :
leaders ℓ t = leaders ℓ' t

Deterministic Greedy (Follow-the-Leader) and Theorem 4.2 #

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.greedyPlay {ι : Type u_1} [Fintype ι] [Nonempty ι] [LinearOrder ι] (ℓ : ℕ → ι → ℝ) (t : ℕ) :
ι

Deterministic Greedy (Follow-the-Leader) [BlumMansour2007AGT, §4.3.1, p. 83]: in round t, select the minimum-index action among leaders ℓ t.

theorem Cslib.MachineLearning.OnlineLearning.Experts.greedyPlay_le {ι : Type u_1} [Fintype ι] [Nonempty ι] [LinearOrder ι] {ℓ : ℕ → ι → ℝ} {t : ℕ} {i : ι} (hi : i ∈ leaders ℓ t) :
greedyPlay ℓ t ≤ i
theorem Cslib.MachineLearning.OnlineLearning.Experts.greedyPlay_congr {ι : Type u_1} [Fintype ι] [Nonempty ι] [LinearOrder ι] {ℓ ℓ' : ℕ → ι → ℝ} {t : ℕ} (h : ∀ s < t, ℓ s = ℓ' s) :
greedyPlay ℓ t = greedyPlay ℓ' t
theorem Cslib.MachineLearning.OnlineLearning.Experts.greedy_loss_le {ι : Type u_1} [Fintype ι] [Nonempty ι] {ℓ : ℕ → ι → ℝ} {x : ℕ → ι} {T : ℕ} (hx : ∀ t < T, x t ∈ leaders ℓ t) (hℓ : ∀ t < T, ∀ (i : ι), ℓ t i ∈ Set.Icc 0 1) :
∑ t ∈ Finset.range T, ℓ t (x t) ≤ ↑(Fintype.card ι) * minCumLoss ℓ T + (↑(Fintype.card ι) - 1)

Greedy external-regret bound [BlumMansour2007AGT, Theorem 4.2, p. 83]: for any tie-breaking sequence x selecting x t ∈ leaders ℓ t and any [0, 1]-valued loss sequence ℓ (in particular any {0, 1} loss sequence), the Greedy learner's total loss satisfies ∑ t ∈ range T, ℓ t (x t) ≤ N * minCumLoss ℓ T + (N - 1).

theorem Cslib.MachineLearning.OnlineLearning.Experts.greedyPlay_loss_le {ι : Type u_1} [Fintype ι] [Nonempty ι] [LinearOrder ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} (hℓ : ∀ t < T, ∀ (i : ι), ℓ t i ∈ Set.Icc 0 1) :
∑ t ∈ Finset.range T, ℓ t (greedyPlay ℓ t) ≤ ↑(Fintype.card ι) * minCumLoss ℓ T + (↑(Fintype.card ι) - 1)

Greedy external-regret bound for greedyPlay [BlumMansour2007AGT, Theorem 4.2, p. 83].

Randomized Greedy and Theorem 4.4 #

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

Randomized Greedy (RG) [BlumMansour2007AGT, §4.3.1, p. 84]: in round t, play the uniform distribution over leaders ℓ t.

theorem Cslib.MachineLearning.OnlineLearning.Experts.randGreedyProb_of_mem {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {t : ℕ} {i : ι} (hi : i ∈ leaders ℓ t) :
randGreedyProb ℓ t i = 1 / ↑(leaders ℓ t).card
theorem Cslib.MachineLearning.OnlineLearning.Experts.randGreedyProb_of_notMem {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {t : ℕ} {i : ι} (hi : i ∉ leaders ℓ t) :
randGreedyProb ℓ t i = 0
theorem Cslib.MachineLearning.OnlineLearning.Experts.randGreedyProb_nonneg {ι : Type u_1} [Fintype ι] (ℓ : ℕ → ι → ℝ) (t : ℕ) (i : ι) :
theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_randGreedyProb {ι : Type u_1} [Fintype ι] [Nonempty ι] (ℓ : ℕ → ι → ℝ) (t : ℕ) :
∑ i : ι, randGreedyProb ℓ t i = 1
theorem Cslib.MachineLearning.OnlineLearning.Experts.randGreedyProb_congr {ι : Type u_1} [Fintype ι] {ℓ ℓ' : ℕ → ι → ℝ} {t : ℕ} (h : ∀ s < t, ℓ s = ℓ' s) :
theorem Cslib.MachineLearning.OnlineLearning.Experts.randGreedy_loss_le_harmonic {ι : Type u_1} [Fintype ι] [Nonempty ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} (hℓ : ∀ t < T, ∀ (i : ι), ℓ t i = 0 ∨ ℓ t i = 1) :
∑ t ∈ Finset.range T, ∑ i : ι, randGreedyProb ℓ t i * ℓ t i ≤ ↑(harmonic (Fintype.card ι)) - ↑(harmonic (leaders ℓ T).card) + ↑(harmonic (Fintype.card ι)) * minCumLoss ℓ T

Harmonic invariant for Randomized Greedy [BlumMansour2007AGT, proof of Theorem 4.4, p. 84]: on {0, 1} loss sequences, L_RG^T ≤ (H_N - H_{|S^T|}) + H_N * L_min^T.

theorem Cslib.MachineLearning.OnlineLearning.Experts.randGreedy_loss_le_log {ι : Type u_1} [Fintype ι] [Nonempty ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} (hℓ : ∀ t < T, ∀ (i : ι), ℓ t i = 0 ∨ ℓ t i = 1) :
∑ t ∈ Finset.range T, ∑ i : ι, randGreedyProb ℓ t i * ℓ t i ≤ Real.log ↑(Fintype.card ι) + (1 + Real.log ↑(Fintype.card ι)) * minCumLoss ℓ T

Logarithmic bound for Randomized Greedy [BlumMansour2007AGT, Theorem 4.4, p. 84]: on {0, 1} loss sequences, L_RG^T ≤ ln N + (1 + ln N) * L_min^T.