Documentation

CslibFrontier.MachineLearning.OnlineLearning.SwapRegret

Swap regret and the Blum–Mansour reduction #

A learner that plays the distribution p t against the losses ℓ t has swap regret at most R if, for every swapping function δ : ι → ι, ∑ t, ∑ i, p t i * ℓ t i ≤ ∑ t, ∑ i, p t i * ℓ t (δ i) + R: replacing every play of i by δ i saves at most R ([BM07a], §2; [Rou13], Lecture 18, Definition 1.2). Constant swapping functions recover external regret, the benchmark of hedge_regret_le; swap regret is stronger, and it is the notion whose dynamics converge to correlated rather than coarse correlated equilibria ([BM07a], Theorem 3).

Blum and Mansour reduce swap regret to external regret ([BM07a], §3; [Rou13], Lecture 18, Theorem 2.1). Run one external-regret algorithm per expert. In round t, copy j proposes a distribution, the row q t j of a matrix q t. The learner plays a stationary vector p t ᵥ* q t = p t and charges copy j the scaled losses p t j * ℓ t. Stationarity makes the learner's loss the sum of the losses the copies see, and copy j's external regret against expert δ j covers the deviation j ↦ δ j. So the swap regret is at most the sum of the copies' regrets (swap_regret_le_sum_regret, [BM07a], Theorem 5). The theorem assumes only stationarity and the copies' regret bounds, so it applies to any external-regret algorithms.

With Hedge copies (blumMansourWeight) and the stationary vectors Matrix.stationaryVec, the learner (blumMansourProb) has swap regret at most η T + n ln n / η for losses in [-1, 1] (blumMansour_swap_regret_le). Copy j's second-order term is at most η ∑ t, p t j, so the second-order terms of all copies sum to at most η T. The learning rate η = √(n ln n / T) gives swap regret at most 2 √(T n ln n) once T ≥ n ln n (blumMansour_swap_regret_le_sqrt), the O(√(T N log N)) bound of [BM07a], Corollary 7.

Main definitions #

Main results #

References #

theorem Cslib.MachineLearning.OnlineLearning.Experts.swap_regret_le_sum_regret {ι : Type u_1} [Fintype ι] {p : ℕ → ι → ℝ} {q : ℕ → Matrix ι ι ℝ} {ℓ : ℕ → ι → ℝ} {T : ℕ} {R : ι → ℝ} (hp : ∀ (t : ℕ), Matrix.vecMul (p t) (q t) = p t) (hR : ∀ (j k : ι), ∑ t ∈ Finset.range T, ∑ i : ι, q t j i * (p t j * ℓ t i) ≤ ∑ t ∈ Finset.range T, p t j * ℓ t k + R j) (δ : ι → ι) :
∑ t ∈ Finset.range T, ∑ i : ι, p t i * ℓ t i ≤ ∑ t ∈ Finset.range T, ∑ i : ι, p t i * ℓ t (δ i) + ∑ j : ι, R j

The Blum–Mansour reduction [BlumMansour2007, Theorem 5]. Let the learner play p t, a stationary vector of the matrix q t whose row j is the distribution of copy j, and let copy j see the losses p t j * ℓ t. If copy j has regret at most R j against every expert, then the learner has swap regret at most ∑ j, R j: for every swapping function δ, ∑ t, ⟨p t, ℓ t⟩ ≤ ∑ t, ∑ i, p t i * ℓ t (δ i) + ∑ j, R j.

Hedge copies #

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

The weights of the Hedge copies in the Blum–Mansour algorithm with learning rate η: blumMansourWeight η ℓ t j i is the weight that copy j gives expert i in round t. Copy j sees the losses ℓ t scaled by the learner's probability of j, the j-th entry of a stationary vector of the copies' normalized weights.

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

The copies' distributions in round t: row j is the normalized weights of copy j.

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

The distribution of the Blum–Mansour learner in round t: the chosen stationary vector of blumMansourMatrix.

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

The losses copy j sees: the loss vector ℓ t scaled by the learner's probability of j.

theorem Cslib.MachineLearning.OnlineLearning.Experts.blumMansourLoss_apply {ι : Type u_1} [Fintype ι] [DecidableEq ι] (η : ℝ) (ℓ : ℕ → ι → ℝ) (j : ι) (t : ℕ) (i : ι) :
blumMansourLoss η ℓ j t i = blumMansourProb η ℓ t j * ℓ t i

Copy j sees the loss ℓ t i of expert i scaled by the learner's probability of j.

@[simp]
theorem Cslib.MachineLearning.OnlineLearning.Experts.blumMansourWeight_zero {ι : Type u_1} [Fintype ι] [DecidableEq ι] (η : ℝ) (ℓ : ℕ → ι → ℝ) (j i : ι) :
blumMansourWeight η ℓ 0 j i = 1

Every copy starts with weight 1 on every expert.

theorem Cslib.MachineLearning.OnlineLearning.Experts.blumMansourWeight_succ {ι : Type u_1} [Fintype ι] [DecidableEq ι] (η : ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) (j i : ι) :
blumMansourWeight η ℓ (t + 1) j i = blumMansourWeight η ℓ t j i * hedgeFactor η (blumMansourProb η ℓ t j * ℓ t i)

Copy j multiplies the weight of expert i by the Hedge factor of its scaled loss.

theorem Cslib.MachineLearning.OnlineLearning.Experts.blumMansourWeight_eq_weight {ι : Type u_1} [Fintype ι] [DecidableEq ι] (η : ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) (j : ι) :

Copy j is Hedge run on the losses blumMansourLoss η ℓ j.

theorem Cslib.MachineLearning.OnlineLearning.Experts.blumMansourMatrix_eq_prob {ι : Type u_1} [Fintype ι] [DecidableEq ι] (η : ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) (j : ι) :
blumMansourMatrix η ℓ t j = prob (hedgeFactor η) (blumMansourLoss η ℓ j) t

Row j of blumMansourMatrix is the distribution of Hedge on the losses copy j sees.

The copies' distributions form a row-stochastic matrix.

theorem Cslib.MachineLearning.OnlineLearning.Experts.blumMansourProb_nonneg {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] (η : ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) (i : ι) :
0 ≤ blumMansourProb η ℓ t i

The learner's probabilities are nonnegative.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_blumMansourProb {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] (η : ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) :
∑ i : ι, blumMansourProb η ℓ t i = 1

The learner plays a probability distribution.

theorem Cslib.MachineLearning.OnlineLearning.Experts.blumMansourProb_le_one {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] (η : ℝ) (ℓ : ℕ → ι → ℝ) (t : ℕ) (i : ι) :
blumMansourProb η ℓ t i ≤ 1

The learner's probabilities are at most 1.

The learner's distribution is stationary for the copies' distributions.

theorem Cslib.MachineLearning.OnlineLearning.Experts.blumMansourWeight_congr {ι : Type u_1} [Fintype ι] [DecidableEq ι] {η : ℝ} {ℓ ℓ' : ℕ → ι → ℝ} {t : ℕ} (h : ∀ s < t, ℓ s = ℓ' s) :

The copies' weights in round t depend only on the losses before round t.

theorem Cslib.MachineLearning.OnlineLearning.Experts.blumMansourProb_congr {ι : Type u_1} [Fintype ι] [DecidableEq ι] {η : ℝ} {ℓ ℓ' : ℕ → ι → ℝ} {t : ℕ} (h : ∀ s < t, ℓ s = ℓ' s) :
blumMansourProb η ℓ t = blumMansourProb η ℓ' t

The learner's distribution in round t depends only on the losses before round t: the Blum–Mansour learner is an online algorithm.

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

Swap regret of the Blum–Mansour algorithm with Hedge copies: for losses in [-1, 1] and 0 < η ≤ 1, for every swapping function δ, ∑ t, ⟨p t, ℓ t⟩ ≤ ∑ t, ∑ i, p t i * ℓ t (δ i) + η T + n ln n / η.

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

Tuned swap regret of the Blum–Mansour algorithm [BlumMansour2007, Corollary 7]: for n ≥ 2 experts, losses in [-1, 1] and T ≥ n ln n rounds, Hedge copies with learning rate η = √(n ln n / T) give swap regret at most 2 √(T n ln n).