Hinge Loss (SVM)
Loss for support vector machines; zero once a point is correctly classified with margin.
Formula
Variables
Example
y=1, score=1.5: L=0
How it works
Hinge loss measures how well a classifier separates two classes using a signed score rather than a probability. If the true label y and the model score \u005chat{y} have the same sign and their product is at least 1, the point is not just classified correctly but is also beyond the margin, so the loss becomes zero. If the margin is too small or the point is misclassified, the loss grows linearly, which encourages SVMs to push the decision boundary away from the data for better separation.
When to use it
Use hinge loss when training linear classifiers such as support vector machines or other margin-based models on binary labels coded as -1 and +1. It is especially useful when you want a large safety margin between classes rather than merely correct predictions.
Worked example, step by step
Given y = -1 and \u005chat{y} = 0.4 Step 1: Compute y \u00b7 \u005chat{y} = (-1)(0.4) = -0.4 Step 2: Compute 1 - y\u005chat{y} = 1 - (-0.4) = 1.4 Step 3: Take the maximum with 0: L = max(0, 1.4) = 1.4 Final answer: the hinge loss is 1.4
Common mistakes to avoid
- Using 0/1 labels instead of -1/+1 without converting the formula
- Treating \u005chat{y} like a probability instead of a raw decision score
- Forgetting that the loss is zero only when y\u005chat{y} \u2265 1, not merely when y\u005chat{y} > 0
Did You Know?
Hinge loss only cares about points near or inside the margin — the "support vectors".
Share this formula
More in Machine Learning & AI
View allLinear Regression Model
BasicPredicts a continuous value as a weighted sum of input features plus a bias.
Gradient Descent Update
BasicIteratively moves parameters in the direction that most reduces the loss.
ReLU Activation
BasicRectified Linear Unit: outputs the input if positive, else zero.
Leaky ReLU
BasicA ReLU variant that lets a small gradient flow for negative inputs.
Tanh Activation
BasicSquashes input to the range (-1, 1); zero-centred activation.
Softmax
BasicTurns a vector of scores into a probability distribution that sums to 1.