Documentation

CslibFrontier.MachineLearning.LossMinimization.Hinge

The hinge loss and Soft-SVM #

The hinge loss of a linear predictor w on a point x with label y is max 0 (1 - y ⟪w, x⟫) [ShalevShwartzBenDavid2014, Section 12.3]. It is convex in w and |y| ‖x‖-Lipschitz [ShalevShwartzBenDavid2014, Claim 15.6], so Soft-SVM, Tikhonov regularized minimization of the empirical hinge risk [ShalevShwartzBenDavid2014, (15.6)], inherits the stability and oracle inequality of Cslib.MachineLearning.IsRLM.

Examples z are described by a feature map φ : Z → E and real labels y : Z → ℝ. The source uses labels ±1 and points of norm at most ρ; here |y z| ≤ 1 and ‖φ z‖ ≤ ρ for every z.

Main definitions #

Main results #

References #

noncomputable def Cslib.MachineLearning.hingeLoss {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (w x : E) (y : ℝ) :

The hinge loss max 0 (1 - y ⟪w, x⟫) of the linear predictor w on the point x with label y [ShalevShwartzBenDavid2014, Section 12.3].

theorem Cslib.MachineLearning.hingeLoss_def {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (w x : E) (y : ℝ) :
hingeLoss w x y = max 0 (1 - y * inner ℝ w x)
theorem Cslib.MachineLearning.hingeLoss_eq_zero {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {w x : E} {y : ℝ} (h : 1 ≤ y * inner ℝ w x) :
hingeLoss w x y = 0

The hinge loss vanishes when the margin y ⟪w, x⟫ is at least 1.

The hinge loss is convex in the predictor.

The hinge loss is |y| ‖x‖-Lipschitz in the predictor [ShalevShwartzBenDavid2014, Claim 15.6].

theorem Cslib.MachineLearning.lipschitzWith_hingeLoss_of_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {x : E} {y : ℝ} {ρ : NNReal} (hx : ‖x‖ ≤ ↑ρ) (hy : |y| ≤ 1) :
LipschitzWith ρ fun (w : E) => hingeLoss w x y

With |y| ≤ 1 and ‖x‖ ≤ ρ, the hinge loss is ρ-Lipschitz in the predictor.

theorem Cslib.MachineLearning.IsRLM.integral_trueRisk_hingeLoss_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {Z : Type u_2} [MeasurableSpace Z] {φ : Z → E} {y : Z → ℝ} {ρ : NNReal} (hφ : ∀ (z : Z), ‖φ z‖ ≤ ↑ρ) (hy : ∀ (z : Z), |y z| ≤ 1) {m : ℕ} {r : ℝ} (hr : 0 < r) {A : (Fin m → Z) → E} (hA : IsRLM (fun (w : E) (z : Z) => hingeLoss w (φ z) (y z)) (fun (w : E) => r * ‖w‖ ^ 2) Set.univ A) (D : MeasureTheory.Measure Z) [MeasureTheory.IsProbabilityMeasure D] (hm : 0 < m) (hint : MeasureTheory.Integrable (fun (p : (Fin m → Z) × Z) => hingeLoss (A p.1) (φ p.2) (y p.2)) ((MeasureTheory.Measure.pi fun (x : Fin m) => D).prod D)) (hint' : ∀ (i : Fin m), MeasureTheory.Integrable (fun (S : Fin m → Z) => hingeLoss (A S) (φ (S i)) (y (S i))) (MeasureTheory.Measure.pi fun (x : Fin m) => D)) (u : E) (huint : MeasureTheory.Integrable (fun (z : Z) => hingeLoss u (φ z) (y z)) D) :
(∫ (S : Fin m → Z), trueRisk (fun (w : E) (z : Z) => hingeLoss w (φ z) (y z)) D (A S) ∂MeasureTheory.Measure.pi fun (x : Fin m) => D) ≤ trueRisk (fun (w : E) (z : Z) => hingeLoss w (φ z) (y z)) D u + r * ‖u‖ ^ 2 + 2 * ↑ρ ^ 2 / (r * ↑m)

The Soft-SVM oracle inequality [ShalevShwartzBenDavid2014, Corollary 15.7]: let A be a Soft-SVM rule, a minimizer of the empirical hinge risk plus r‖w‖² with r > 0 over all of E. If every example z has label |y z| ≤ 1 and feature vector ‖φ z‖ ≤ ρ, then for m > 0 i.i.d. examples from D and every u, 𝔼_S [L_D(A S)] ≤ L_D(u) + r‖u‖² + 2ρ² / (r m), where L_D is the true hinge risk.

The integrability hypotheses are those of Cslib.MachineLearning.integral_trueRisk_sub_empiricalRisk; they hold automatically when Z is finite with measurable singletons.