ML0053 Hinge Loss for SVM

Explain the Hinge Loss function used in SVM.

Answer

The hinge loss is the key element of Support Vector Machines: it penalizes both misclassified points and correctly classified points that lie inside the margin. Points classified correctly with margin to spare get zero loss; the loss grows linearly as a point moves toward or across the decision boundary. This structure is exactly what pushes the SVM to maximize the margin, promoting robust, generalizable boundaries.

(1) Zero Loss Zone: When y \cdot f(\mathbf{x}) \geq 1, the point is correctly classified and outside (or exactly on) the margin, the loss is 0.
(2) Linear Penalty Zone: When y \cdot f(\mathbf{x}) falls below 1, i.e., inside the margin or misclassified, the loss grows linearly with the violation.
(3) Convex But Not Smooth: The kink at y \cdot f(\mathbf{x}) = 1 makes the function non-differentiable there, so optimization uses subgradients instead of plain gradients.

Hinge loss curve at zero beyond margin one and increasing linearly for smaller or negative margins with a kink at one

Figure 1: Hinge loss vs the margin y \cdot f(\mathbf{x}): flat at zero once the point is beyond the margin (right of the dashed line at 1), ramping up linearly inside the margin and for misclassified points (left of it). The kink at 1 is where subgradients take over.

Mathematical Formulation:
\text{Hinge Loss} = \max\big(0,\; 1 - y \cdot f(\mathbf{x})\big)

Where:

  • y \in \{-1, +1\} is the true label.
  • f(\mathbf{x}) is the raw model output (the signed score, before any threshold).
  • The product y \cdot f(\mathbf{x}) is the (functional) margin: positive means correctly classified, ≥ 1 means correct with margin.

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *