Documentation

CslibFrontier.MachineLearning.OnlineLearning.Hedge

The Hedge algorithm #

The Hedge algorithm of Freund and Schapire [FS97] with learning rate η multiplies the weight of an expert with loss x by exp (-η x) (hedgeFactor) [AroraHazanKale2012, §2.1, (2.6)]. For losses in [-1, 1] and 0 < η ≤ 1, its total expected loss exceeds the total loss of every expert i by at most η ∑ t, ⟨p t, ℓ t ^ 2⟩ + ln n / η (hedge_regret_le, [AroraHazanKale2012, Theorem 2.3]). Here the second-order term is the learner's expected squared loss, not the expert's.

[AHK12] states Theorem 2.3 without proof, indicating only that the analysis follows that of Theorem 2.1 with the estimate exp (-η x) ≤ 1 - η x + η ^ 2 x ^ 2 for |η x| ≤ 1. The proof here is that argument, carried out from the potential inequality sum_log_le_log_card_add. The factor of expert i contributes exactly -η ℓ t i to the logarithm. The expected update factor is at most 1 - η ⟨p t, ℓ t⟩ + η ^ 2 ⟨p t, ℓ t ^ 2⟩ by Real.exp_neg_le_one_sub_add_sq (which needs only η x ≥ -1), and log (1 + x) ≤ x. The hypothesis is thus one-sided (hedge_regret_le_of_neg_one_le).

Since the learner's expected squared loss is at most 1 for losses in [-1, 1], the learning rate η = √(ln n / T) gives regret at most 2 √(T ln n) once T ≥ ln n (hedge_regret_le_sqrt), by the balancing identity sqrt_div_mul_add_div_sqrt_div.

Main definitions #

Main results #

References #

The update factor exp (-η x) of the Hedge algorithm with learning rate η [AroraHazanKale2012, (2.6)].

theorem Cslib.MachineLearning.OnlineLearning.Experts.hedge_regret_le_of_nonneg {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} {η : ℝ} (hη : 0 < η) (hℓ : ∀ s < T, ∀ (i : ι), 0 ≤ ℓ s i) (i : ι) :
∑ t ∈ Finset.range T, ∑ j : ι, prob (hedgeFactor η) ℓ t j * ℓ t j ≤ ∑ t ∈ Finset.range T, ℓ t i + η / 2 * ∑ t ∈ Finset.range T, ∑ j : ι, prob (hedgeFactor η) ℓ t j * ℓ t j ^ 2 + Real.log ↑(Fintype.card ι) / η

Regret of Hedge for nonnegative losses: for 0 < η, losses ℓ ≥ 0, and every expert i, ∑ t, ⟨p t, ℓ t⟩ ≤ ∑ t, ℓ t i + (η / 2) ∑ t, ⟨p t, ℓ t ^ 2⟩ + ln n / η. Using exp (-x) ≤ 1 - x + x ^ 2 / 2 for x ≥ 0 (Real.exp_neg_le_one_sub_add_sq_div_two) saves a factor of 2 on the variance term without upper-bounding η ℓ (compare the potential step of [BubeckCesaBianchi2012, Theorem 3.1], locator not re-verified against primary PDF).

theorem Cslib.MachineLearning.OnlineLearning.Experts.hedge_regret_le_of_neg_one_le {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} {η : ℝ} (hη : 0 < η) (hℓ : ∀ s < T, ∀ (i : ι), -1 ≤ η * ℓ s i) (i : ι) :
∑ t ∈ Finset.range T, ∑ j : ι, prob (hedgeFactor η) ℓ t j * ℓ t j ≤ ∑ t ∈ Finset.range T, ℓ t i + η * ∑ t ∈ Finset.range T, ∑ j : ι, prob (hedgeFactor η) ℓ t j * ℓ t j ^ 2 + Real.log ↑(Fintype.card ι) / η

Regret of Hedge for losses with η ℓ ≥ -1: for 0 < η and every expert i, ∑ t, ⟨p t, ℓ t⟩ ≤ ∑ t, ℓ t i + η ∑ t, ⟨p t, ℓ t ^ 2⟩ + ln n / η.

theorem Cslib.MachineLearning.OnlineLearning.Experts.hedge_regret_le {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} {η : ℝ} (hη : 0 < η) (hη' : η ≤ 1) (hℓ : ∀ s < T, ∀ (i : ι), |ℓ s i| ≤ 1) (i : ι) :
∑ t ∈ Finset.range T, ∑ j : ι, prob (hedgeFactor η) ℓ t j * ℓ t j ≤ ∑ t ∈ Finset.range T, ℓ t i + η * ∑ t ∈ Finset.range T, ∑ j : ι, prob (hedgeFactor η) ℓ t j * ℓ t j ^ 2 + Real.log ↑(Fintype.card ι) / η

Regret of Hedge [AroraHazanKale2012, Theorem 2.3]: for losses in [-1, 1] and 0 < η ≤ 1, for every expert i, ∑ t, ⟨p t, ℓ t⟩ ≤ ∑ t, ℓ t i + η ∑ t, ⟨p t, ℓ t ^ 2⟩ + ln n / η.

theorem Cslib.MachineLearning.OnlineLearning.Experts.hedge_regret_le_sqrt {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} (hn : 2 ≤ Fintype.card ι) (hT : Real.log ↑(Fintype.card ι) ≤ ↑T) (hℓ : ∀ s < T, ∀ (i : ι), |ℓ s i| ≤ 1) (i : ι) :
∑ t ∈ Finset.range T, ∑ j : ι, prob (hedgeFactor √(Real.log ↑(Fintype.card ι) / ↑T)) ℓ t j * ℓ t j ≤ ∑ t ∈ Finset.range T, ℓ t i + 2 * √(↑T * Real.log ↑(Fintype.card ι))

Tuned regret of Hedge: for n ≥ 2 experts, losses in [-1, 1] and T ≥ ln n rounds, Hedge with learning rate η = √(ln n / T) has regret at most 2 √(T ln n) against every expert. The condition T ≥ ln n is η ≤ 1, and the learner's expected squared loss is at most 1 in every round.