Hinge loss

In machine learning, the hinge loss is a loss function used for training classifiers. The hinge loss is used for "maximum-margin" classification, most notably for support vector machines (SVMs).[1]
For an intended output Template:Math and a classifier score Template:Mvar, the hinge loss of the prediction Template:Mvar is defined as
Note that should be the "raw" output of the classifier's decision function, not the predicted class label. For instance, in linear SVMs, , where are the parameters of the hyperplane and is the input variable(s).
When Template:Mvar and Template:Mvar have the same sign (meaning Template:Mvar predicts the right class) and , the hinge loss . When they have opposite signs, increases linearly with Template:Mvar, and similarly if , even if it has the same sign (correct prediction, but not by enough margin).
Extensions
While binary SVMs are commonly extended to multiclass classification in a one-vs.-all or one-vs.-one fashion,[2] it is also possible to extend the hinge loss itself for such an end. Several different variations of multiclass hinge loss have been proposed.[3] For example, Crammer and Singer[4] defined it for a linear classifier as[5]
- ,
where is the target label, and are the model parameters.
Weston and Watkins provided a similar definition, but with a sum rather than a max:[6][3]
- .
In structured prediction, the hinge loss can be further extended to structured output spaces. Structured SVMs with margin rescaling use the following variant, where Template:Math denotes the SVM's parameters, Template:Math the SVM's predictions, Template:Mvar the joint feature function, and Template:Math the Hamming loss:
- .
Optimization
The hinge loss is a convex function, so many of the usual convex optimizers used in machine learning can work with it. It is not differentiable, but has a subgradient with respect to model parameters Template:Math of a linear SVM with score function that is given by

However, since the derivative of the hinge loss at is undefined, smoothed versions may be preferred for optimization, such as Rennie and Srebro's[7]
or the quadratically smoothed
suggested by Zhang.[8] The modified Huber loss is a special case of this loss function with , specifically .