Documentation

CslibFrontier.MachineLearning.OnlineLearning.WeightedMajority

The weighted majority algorithm #

In prediction from expert advice [LW94], [AroraHazanKale2012, §1.1], each round t the experts ι give binary advice advice t i, the learner predicts a bit, and then the outcome outcome t is revealed. The weighted majority algorithm with parameter η keeps a weight for each expert, starting at 1 and multiplied by 1 - η whenever the expert errs [AroraHazanKale2012, (1.1)]. It predicts the bit advised by the larger total weight. These are the multiplicative weights for the losses expertLoss, 1 for a wrong expert and 0 otherwise, so the weight of expert i in round t is (1 - η) ^ mᵢ(t), where mᵢ(t) counts its mistakes (weight_mwFactor_expertLoss).

For 0 < η ≤ 1 / 2, the number of mistakes M(T) of weighted majority, with ties broken arbitrarily, satisfies M(T) ≤ 2 (1 + η) mᵢ(T) + 2 ln n / η for every expert i (wm_mistakes_le, [AroraHazanKale2012, Theorem 1.1]). Tie-breaking is a hypothesis on the predictions (the advice they reject never outweighs the advice they follow), so the theorem covers every tie-breaking rule. The rule weightedMajority, which breaks ties towards true, satisfies it (weightedMajority_mistakes_le).

The proof is that of [AHK12]: in a round with a mistake, the experts that agreed with the prediction were wrong and carry at least half of the weight, so the learner's expected loss is at least 1 / 2 and the potential shrinks by the factor 1 - η / 2. It is phrased through the potential inequality sum_log_le_log_card_add, with -ln (1 - η) ≤ η + η ^ 2 (Real.neg_sub_sq_le_log_one_sub).

Main definitions #

Main results #

References #

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.expertLoss {ι : Type u_1} (advice : ℕ → ι → Bool) (outcome : ℕ → Bool) (t : ℕ) (i : ι) :

The loss of expert i in round t: 1 if its advice is wrong, 0 otherwise.

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.weightedMajority {ι : Type u_1} [Fintype ι] (advice : ℕ → ι → Bool) (outcome : ℕ → Bool) (η : ℝ) (t : ℕ) :

The weighted majority prediction in round t: the bit advised by the larger total weight, with ties broken towards true.

theorem Cslib.MachineLearning.OnlineLearning.Experts.weight_mwFactor_expertLoss {ι : Type u_1} (advice : ℕ → ι → Bool) (outcome : ℕ → Bool) (η : ℝ) (t : ℕ) (i : ι) :
weight (mwFactor η) (expertLoss advice outcome) t i = (1 - η) ^ {s ∈ Finset.range t | advice s i ≠ outcome s}.card

The weight of expert i in round t is (1 - η) ^ mᵢ(t), where mᵢ(t) is the number of its mistakes before round t [AroraHazanKale2012, (1.1)].

theorem Cslib.MachineLearning.OnlineLearning.Experts.wm_mistakes_le {ι : Type u_1} [Fintype ι] {T : ℕ} {advice : ℕ → ι → Bool} {outcome : ℕ → Bool} {η : ℝ} (hη : 0 < η) (hη' : η ≤ 1 / 2) (pred : ℕ → Bool) (hpred : ∀ t < T, ∑ i : ι with advice t i ≠ pred t, weight (mwFactor η) (expertLoss advice outcome) t i ≤ ∑ i : ι with advice t i = pred t, weight (mwFactor η) (expertLoss advice outcome) t i) (i : ι) :
↑{t ∈ Finset.range T | pred t ≠ outcome t}.card ≤ 2 * (1 + η) * ↑{t ∈ Finset.range T | advice t i ≠ outcome t}.card + 2 * Real.log ↑(Fintype.card ι) / η

The weighted majority algorithm [AroraHazanKale2012, Theorem 1.1]: let 0 < η ≤ 1 / 2, and let pred be weighted majority predictions with arbitrary tie-breaking, that is, in each round t < T the weight of the experts advising against pred t is at most that of the experts advising pred t. Then for every expert i, the number of mistakes is M(T) ≤ 2 (1 + η) mᵢ(T) + 2 ln n / η.

theorem Cslib.MachineLearning.OnlineLearning.Experts.weightedMajority_spec {ι : Type u_1} [Fintype ι] {advice : ℕ → ι → Bool} {outcome : ℕ → Bool} (η : ℝ) (t : ℕ) :
∑ i : ι with advice t i ≠ weightedMajority advice outcome η t, weight (mwFactor η) (expertLoss advice outcome) t i ≤ ∑ i : ι with advice t i = weightedMajority advice outcome η t, weight (mwFactor η) (expertLoss advice outcome) t i

weightedMajority follows the advice of the larger total weight.

theorem Cslib.MachineLearning.OnlineLearning.Experts.weightedMajority_mistakes_le {ι : Type u_1} [Fintype ι] {T : ℕ} {advice : ℕ → ι → Bool} {outcome : ℕ → Bool} {η : ℝ} (hη : 0 < η) (hη' : η ≤ 1 / 2) (i : ι) :
↑{t ∈ Finset.range T | weightedMajority advice outcome η t ≠ outcome t}.card ≤ 2 * (1 + η) * ↑{t ∈ Finset.range T | advice t i ≠ outcome t}.card + 2 * Real.log ↑(Fintype.card ι) / η

The weighted majority algorithm [AroraHazanKale2012, Theorem 1.1], for the rule weightedMajority: for 0 < η ≤ 1 / 2 and every expert i, M(T) ≤ 2 (1 + η) mᵢ(T) + 2 ln n / η.