Documentation

CslibFrontier.MachineLearning.OnlineLearning.MultiplicativeWeights

The multiplicative weights algorithm #

The multiplicative weights (MW) algorithm with learning rate η multiplies the weight of an expert with loss x by 1 - η x (mwFactor) [AroraHazanKale2012, §2, Figure 1]; this is the prod algorithm of Cesa-Bianchi, Mansour and Stoltz [CBMS07] and the Polynomial Weights (PW) algorithm of Blum and Mansour [BlumMansour2007AGT, §4.3.3] (which coincides with Randomized Weighted Majority on {0, 1} losses [BlumMansour2007AGT, §4.3.2]). For losses in [-1, 1] and 0 < η ≤ 1 / 2, its total expected loss exceeds the total loss of every expert i by at most η ∑ t, |ℓ t i| + ln n / η (mw_regret_le, [AroraHazanKale2012, Theorem 2.1]). Averaging over a distribution on the experts gives the same bound against mixed strategies (mw_regret_le_stdSimplex, [AroraHazanKale2012, Corollary 2.2]), with η = √(ln n / T) and T ≥ 4 ln n the regret is at most 2 √(T ln n) (mw_regret_le_sqrt), and on [0, 1] losses the capped rate η = min √(ln n / T) (1 / 2) achieves 2 √(T ln n) for every horizon T (mw_regret_le_sqrt_of_mem_Icc, [BlumMansour2007AGT, Theorems 4.5 and 4.6]).

The proof combines the potential inequality sum_log_le_log_card_add with two estimates. The expected update factor is 1 - η times the expected loss, and log (1 - x) ≤ -x. For the factor of expert i, log (1 - y) ≥ -y - y ^ 2 for y ≤ 1 / 2 (Real.neg_sub_sq_le_log_one_sub); this gives the second-order bound η ∑ t, ℓ t i ^ 2 in place of η ∑ t, |ℓ t i| under the one-sided hypothesis η ℓ ≤ 1 / 2 alone (mw_regret_le_sq). [AroraHazanKale2012, proof of Theorem 2.1] uses the two convexity bounds (1 - η) ^ x ≤ 1 - η x on [0, 1] and (1 + η) ^ (-x) ≤ 1 - η x on [-1, 0] instead, followed by the same logarithm estimates at x = ±1.

Main definitions #

Main results #

References #

The update factor 1 - η x of the multiplicative weights algorithm with learning rate η [AroraHazanKale2012, (2.1)].

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_prob_mul_mwFactor {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {t : ℕ} [Nonempty ι] {η : ℝ} (hφ : ∀ s < t, ∀ (i : ι), 0 < mwFactor η (ℓ s i)) :
∑ i : ι, prob (mwFactor η) ℓ t i * mwFactor η (ℓ t i) = 1 - η * ∑ i : ι, prob (mwFactor η) ℓ t i * ℓ t i

The expected MW update factor is 1 - η times the expected loss.

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

Second-order regret of multiplicative weights: if 0 < η and η ℓ ≤ 1 / 2 for all losses, then for every expert i the total expected loss is at most ∑ t, ℓ t i + η ∑ t, ℓ t i ^ 2 + ln n / η. Compare [CBMS07] and [AroraHazanKale2012, Theorem 2.1].

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

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

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

Regret against mixed strategies [AroraHazanKale2012, Corollary 2.2]: for losses in [-1, 1], 0 < η ≤ 1 / 2 and every distribution q on the experts, ∑ t, ⟨p t, ℓ t⟩ ≤ ∑ t, ⟨q, ℓ t + η |ℓ t|⟩ + ln n / η.

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

Tuned regret of multiplicative weights: for n ≥ 2 experts, losses in [-1, 1] and T ≥ 4 ln n rounds, MW with learning rate η = √(ln n / T) has regret at most 2 √(T ln n) against every expert. The condition T ≥ 4 ln n is η ≤ 1 / 2.

theorem Cslib.MachineLearning.OnlineLearning.Experts.prob_regret_le_sqrt_of_mem_Icc {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} {φ : ℝ → ℝ → ℝ} (i : ι) (hpos0 : ∀ x ∈ Set.Icc 0 1, 0 < φ 0 x) (hpos_half : ∀ x ∈ Set.Icc 0 1, 0 < φ (1 / 2) x) (hreg : ∀ {η : ℝ}, 0 < η → η ≤ 1 / 2 → ∑ t ∈ Finset.range T, ∑ j : ι, prob (φ η) ℓ t j * ℓ t j ≤ (1 + η) * ∑ t ∈ Finset.range T, ℓ t i + Real.log ↑(Fintype.card ι) / η) (hℓ : ∀ s < T, ∀ (j : ι), ℓ s j ∈ Set.Icc 0 1) :
∑ t ∈ Finset.range T, ∑ j : ι, prob (φ (min (√(Real.log ↑(Fintype.card ι) / ↑T)) (1 / 2))) ℓ t j * ℓ t j ≤ ∑ t ∈ Finset.range T, ℓ t i + 2 * √(↑T * Real.log ↑(Fintype.card ι))

Generic capped-rate 2 √(T ln n) external regret wrapper on [0, 1] losses for any multiplicative update family φ η satisfying (1 + η) L_i^T + ln n / η for 0 < η ≤ 1 / 2.

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

Tuned regret of multiplicative weights on [0, 1] losses for every horizon [BlumMansour2007AGT, Theorems 4.5 and 4.6, pp. 85–87]: for losses in [0, 1] and every horizon T : ℕ, MW with the capped learning rate η = min √(ln n / T) (1 / 2) has regret at most 2 √(T ln n) against every expert i. On {0, 1} losses mwFactor coincides with Randomized Weighted Majority ((1 - η) ^ ℓ = 1 - η ℓ), so together with mw_regret_le (for binary losses) and mw_regret_le_sq (for [0, 1] losses) this covers the tuned bounds of Theorems 4.5 and 4.6 without the horizon floor T ≥ 4 ln n of mw_regret_le_sqrt.

theorem Cslib.MachineLearning.OnlineLearning.Experts.mw_regret_le_sq_tuned {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} {Q : ℝ} (hQ0 : 0 ≤ Q) (hℓ : ∀ s < T, ∀ (i : ι), |ℓ s i| ≤ 1) (i : ι) (hQ : ∑ t ∈ Finset.range T, ℓ t i ^ 2 ≤ Q) :
have η := if 4 * Real.log ↑(Fintype.card ι) < Q then √(Real.log ↑(Fintype.card ι) / Q) else 1 / 2; ∑ t ∈ Finset.range T, ∑ j : ι, prob (mwFactor η) ℓ t j * ℓ t j ≤ ∑ t ∈ Finset.range T, ℓ t i + 2 * √(Q * Real.log ↑(Fintype.card ι)) + 2 * Real.log ↑(Fintype.card ι)

Second-order tuned regret of multiplicative weights (O(√(Q ln n) + ln n)): for losses in [-1, 1] and any upper bound Q ≥ 0 on ∑ t < T, (ℓ t i) ^ 2, choosing the capped learning rate η = if 4 * ln n < Q then √(ln n / Q) else 1 / 2 (which depends only on n and Q, not on i or T) gives ∑ t, ⟨p t, ℓ t⟩ ≤ ∑ t, ℓ t i + 2 √(Q ln n) + 2 ln n for every n ≥ 1 and every Q ≥ 0.

theorem Cslib.MachineLearning.OnlineLearning.Experts.mw_regret_le_sqrt_loss_add_log {ι : Type u_1} [Fintype ι] {ℓ : ℕ → ι → ℝ} {T : ℕ} {L : ℝ} (hL0 : 0 ≤ L) (hℓ : ∀ s < T, ∀ (i : ι), ℓ s i ∈ Set.Icc 0 1) (i : ι) (hL : ∑ t ∈ Finset.range T, ℓ t i ≤ L) :
have η := if 4 * Real.log ↑(Fintype.card ι) < L then √(Real.log ↑(Fintype.card ι) / L) else 1 / 2; ∑ t ∈ Finset.range T, ∑ j : ι, prob (mwFactor η) ℓ t j * ℓ t j ≤ ∑ t ∈ Finset.range T, ℓ t i + 2 * √(L * Real.log ↑(Fintype.card ι)) + 2 * Real.log ↑(Fintype.card ι)

First-order (L_min-tuned) regret bound on [0, 1] losses [BlumMansour2007AGT, §4.3.2 note after Theorem 4.5, p. 85]: for losses in [0, 1] and any upper bound L ≥ 0 on ∑ t < T, ℓ t i (in particular L = minCumLoss ℓ T), tuning η = if 4 * ln n < L then √(ln n / L) else 1 / 2 achieves ∑ t, ⟨p t, ℓ t⟩ ≤ ∑ t, ℓ t i + 2 √(L ln n) + 2 ln n. The additive 2 ln n term is necessary when L < 4 ln n (for instance L = 0), correcting the omitted + 2 ln N in the parenthetical remark on p. 85.

Payoff-maximizing Polynomial Weights on [-1, 1] payoffs (NRTV Exercise 4.4) #

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

Second-order external regret for payoff-maximizing Polynomial Weights [BlumMansour2007AGT, Exercise 4.4, p. 101]: when payoffs g t i lie in [-1, 1] and the learner multiplies weights by 1 + η * g t i = mwFactor (-η) (g t i) with 0 < η ≤ 1 / 2, for every expert i the shortfall below expert i's total payoff is at most η * ∑ t < T, (g t i) ^ 2 + ln n / η.

theorem Cslib.MachineLearning.OnlineLearning.Experts.mw_gain_regret_le_sqrt_add_log {ι : Type u_1} [Fintype ι] {T : ℕ} {g : ℕ → ι → ℝ} {Q : ℝ} (hQ0 : 0 ≤ Q) (hg : ∀ s < T, ∀ (i : ι), |g s i| ≤ 1) (i : ι) (hQ : ∑ t ∈ Finset.range T, g t i ^ 2 ≤ Q) :
have η := if 4 * Real.log ↑(Fintype.card ι) < Q then √(Real.log ↑(Fintype.card ι) / Q) else 1 / 2; ∑ t ∈ Finset.range T, g t i - ∑ t ∈ Finset.range T, ∑ j : ι, prob (mwFactor (-η)) g t j * g t j ≤ 2 * √(Q * Real.log ↑(Fintype.card ι)) + 2 * Real.log ↑(Fintype.card ι)

Tuned O(√(Q_max ln n) + ln n) regret for payoff-maximizing Polynomial Weights [BlumMansour2007AGT, Exercise 4.4, p. 101]: for payoffs g t i ∈ [-1, 1] and any upper bound Q ≥ 0 with ∑ t < T, (g t i) ^ 2 ≤ Q (e.g. Q = Q_max^T ≥ Q_k^T for all k), running Polynomial Weights with weight factor 1 + η * g = mwFactor (-η) g and capped rate η = if 4 * ln n < Q then √(ln n / Q) else 1 / 2 guarantees ∑ t < T, g t i - ∑ t < T, ⟨p t, g t⟩ ≤ 2 √(Q ln n) + 2 ln n.