Documentation

CslibFrontier.MachineLearning.OnlineLearning.MistakeBound.Perceptron

The perceptron mistake bound #

The perceptron [Nov62] [Blo62] [ShalevShwartzBenDavid2014, §21.4] is an online learner on a real inner product space E. It keeps a weight vector w, starting at 0, predicts true on x iff 0 < ⟪w, x⟫, and on a mistake on the example (x, y) updates w ← w + s(y) • x, where s(y) = ±1 is the signed label (signedLabel). The weight vector is a function of the history (perceptronWeight), so the perceptron is an OnlineLearner E Bool.

Novikoff's theorem. Suppose that some u : E separates the sequence with margin γ ≥ 0, that is, γ ≤ s(y) ⟪u, x⟫ for every example, and that every instance has norm at most R. Then the number M of mistakes satisfies M γ² ≤ R² ‖u‖² (mistakes_perceptron_mul_sq_le). For a unit separator and γ > 0, this is M ≤ (R / γ)² (mistakes_perceptron_le), independent of the length of the sequence and of the dimension of E. The proof tracks two quantities over the mistakes: ⟪u, w⟫ grows by at least γ per mistake, while ‖w‖² grows by at most R² because the prediction was wrong; Cauchy–Schwarz combines them.

The hypothesis 0 ≤ γ is needed: with u = 0 and γ < 0 the margin condition holds for every sequence, while the bound M γ² ≤ 0 fails as soon as the perceptron errs. A positive margin makes the sequence realizable by the halfspace x ↦ decide (0 < ⟪u, x⟫) (realizable_of_margin). The bound is stated per sequence: the margin is a property of the instances presented, not only of the target concept.

Main definitions #

Main results #

References #

The ±1 encoding of a Boolean label: true ↦ 1, false ↦ -1.

One step of the perceptron on the example p = (x, y): keep w if its prediction 0 < ⟪w, x⟫ is correct, and otherwise add s(y) • x.

The perceptron's weight vector after the history h, starting from 0.

The perceptron [Nov62] [ShalevShwartzBenDavid2014, §21.4]: predict true on x iff 0 < ⟪w, x⟫ for the current weight vector w.

theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.perceptron_invariant {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (u : E) {γ R : ℝ} (h S : List (E × Bool)) (hmargin : ∀ p ∈ S, γ ≤ signedLabel p.2 * inner ℝ u p.1) (hR : ∀ p ∈ S, ‖p.1‖ ≤ R) :

The two invariants of the perceptron after the history h, over the rounds S: each mistake increases ⟪u, w⟫ by at least γ and ‖w‖² by at most R².

theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.mistakes_perceptron_mul_sq_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (u : E) {γ R : ℝ} (hγ : 0 ≤ γ) (S : List (E × Bool)) (hmargin : ∀ p ∈ S, γ ≤ signedLabel p.2 * inner ℝ u p.1) (hR : ∀ p ∈ S, ‖p.1‖ ≤ R) :
↑(mistakes perceptron S) * γ ^ 2 ≤ R ^ 2 * ‖u‖ ^ 2

Novikoff's perceptron convergence theorem [Nov62] [Blo62] [ShalevShwartzBenDavid2014, §21.4]: if u separates the sequence S with margin γ ≥ 0 and all instances have norm at most R, then the perceptron makes M mistakes on S with M γ² ≤ R² ‖u‖².

theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.mistakes_perceptron_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (u : E) (hu : ‖u‖ ≤ 1) {γ R : ℝ} (hγ : 0 < γ) (S : List (E × Bool)) (hmargin : ∀ p ∈ S, γ ≤ signedLabel p.2 * inner ℝ u p.1) (hR : ∀ p ∈ S, ‖p.1‖ ≤ R) :
↑(mistakes perceptron S) ≤ (R / γ) ^ 2

The perceptron bound for a separator of norm at most 1 and margin γ > 0: at most (R / γ)² mistakes [ShalevShwartzBenDavid2014, §21.4].

theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.realizable_of_margin {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (u : E) {γ : ℝ} (hγ : 0 < γ) (S : List (E × Bool)) (hmargin : ∀ p ∈ S, γ ≤ signedLabel p.2 * inner ℝ u p.1) :
Realizable {fun (x : E) => decide (0 < inner ℝ u x)} S

A sequence separated by u with a positive margin is realizable by the halfspace x ↦ decide (0 < ⟪u, x⟫).