HingeLoss Class


Hinge Loss, commonly used in classification tasks.

public sealed class HingeLoss : Microsoft.ML.Trainers.ILossFunction<float,float>, Microsoft.ML.Trainers.ISupportSdcaClassificationLoss
type HingeLoss = class
    interface ISupportSdcaClassificationLoss
    interface ISupportSdcaLoss
    interface IScalarLoss
    interface ILossFunction<single, single>
    interface IClassificationLoss
Public NotInheritable Class HingeLoss
Implements ILossFunction(Of Single, Single), ISupportSdcaClassificationLoss


The Hinge Loss function is defined as:

$L(\hat{y}, y) = max(0, m - y\hat{y})$

where $\hat{y}$ is the predicted score, $y \in \{-1, 1\}$ is the true label, and $m$ is the margin parameter set to 1 by default.

Note that the labels used in this calculation are -1 and 1, unlike Log Loss, where the labels used are 0 and 1. Also unlike Log Loss, $\hat{y}$ is the raw predicted score, not the predicted probability (which is calculated by applying a sigmoid function to the predicted score).

While the hinge loss function is both convex and continuous, it is not smooth (that is not differentiable) at $y\hat{y} = m$. Consequently, it cannot be used with gradient descent methods or stochastic gradient descent methods, which rely on differentiability over the entire domain.

For more, see Hinge Loss for classification.




Derivative(Single, Single)
DualLoss(Single, Single)
DualUpdate(Single, Single, Single, Single, Int32)
Loss(Single, Single)

Applies to