How to use this calculator
Calculate average hinge loss from binary class labels and raw decision scores.
- Enter True labels y, Raw decision scores f. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
How this calculation works
Hinge loss evaluates both classification direction and margin size. Each expected class is encoded as −1 or +1, and its paired model score is treated as a signed decision value rather than a probability.
Inputs and units
labels— True labels y- Enter one binary label per example, using only +1 and −1, separated by commas.
decisionScores— Raw decision scores f- Enter one signed model score for each label in the same order; these are not probabilities.
Formula
L̄ = (1/N) × Σ max(0, 1 − yᵢfᵢ); margin violations = count(yᵢfᵢ < 1); mean signed margin = (1/N) × Σ yᵢfᵢ, where yᵢ ∈ {−1, +1} is the class label and fᵢ is its raw decision score.
Method
For every aligned label and score, multiply the label by the score to get the signed margin. The example’s loss is the positive remainder below a margin of one, or zero if the margin reaches one. The reported mean is the arithmetic average across examples.
Worked example
For labels +1, −1, +1 and scores 0.8, −0.6, 2, the signed margins are 0.8, 0.6, and 2. The losses are 0.2, 0.4, and 0, giving a mean hinge loss of 0.2 across three examples.
Assumptions and limits
This binary form requires labels of exactly −1 or +1 and real-valued decision scores. Scores are not probabilities. Because the loss depends on score scale, compare models only when score conventions are consistent. The result is a loss summary, not an accuracy percentage.
Frequently asked questions
What score should I enter?
Use the model’s raw signed decision value for the positive direction, not a calibrated probability.
Does a correct prediction always have zero loss?
No. A correctly signed margin below 1 still has positive hinge loss; zero loss begins at a margin of at least 1.
Can I compare hinge loss with cross-entropy loss?
They use different penalties and score conventions. Treat them as separate objectives and compare only with the model setup clearly defined.
How do I use the Binary Hinge Loss Calculator?
Enter True labels y, Raw decision scores f. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Binary Hinge Loss?
For labels +1, −1, +1 and scores 0.8, −0.6, 2, the signed margins are 0.8, 0.6, and 2. The losses are 0.2, 0.4, and 0, giving a mean hinge loss of 0.2 across three examples.
Reference: scikit-learn API definition of binary hinge loss. See our calculation methodology.