Tutorials › Statistical Learning (Graduate) › The Hinge Loss Calibration Function

Surrogate Losses and Calibration · Tutorial 522 of 989

The Hinge Loss Calibration Function

See why the hinge loss pays exactly the conditional classification regret when a score is constrained to the wrong side.

Advanced 9 min read

What You'll Learn

  • Define the hinge loss conditional risk and the calibration function used here.
  • Minimize conditional hinge risk over correct-sign and incorrect-sign scores.
  • Derive the exact calibration function for every ε from zero to one.
  • Check the result in symmetric and asymmetric conditional examples.
  • Identify why including the boundary score in the constrained infimum matters.

Conditional Risk and the Calibration Question

A margin loss evaluates a real-valued score \(t\) through the signed margin \(Yt\). For the hinge loss, a score is penalized whenever its signed margin is below one. To understand what this loss guarantees for classification, we compare its smallest possible conditional risk with the smallest risk attainable when the score is on the wrong side of the decision boundary.

Fix a feature value and write \(\eta=P(Y=1\mid X=x)\), where \(Y\) takes values in \(\{-1,+1\}\). The conditional classification regret of choosing the wrong sign is \(|2\eta-1|\): it is the conditional probability of the more likely class minus that of the less likely class. The hinge loss is \(\phi(u)=(1-u)_+\), where \(a_+=\max(a,0)\).

Definition: For \(\eta\in[0,1]\) and score \(t\in\mathbb{R}\), the conditional hinge risk is \(R_\eta(t)=\eta(1-t)_+ +(1-\eta)(1+t)_+\). Its unrestricted infimum is \(H(\eta)=\inf_{t\in\mathbb{R}}R_\eta(t)\). The wrong-side constrained infimum is \(H^-(\eta)=\inf_{t:\,t(2\eta-1)\leq 0}R_\eta(t)\). The hinge calibration function on \([0,1]\) is \(\psi(\epsilon)=\inf_{\eta:\,|2\eta-1|\geq\epsilon}\{H^-(\eta)-H(\eta)\}\).

The weak inequality in the score constraint includes \(t=0\), the decision boundary. Thus \(H^-(\eta)\) is an infimum over scores that do not have a strictly correct sign. This convention gives a well-defined constrained minimum even when an incorrect-sign score is approached only as a limit. The parameter \(\epsilon\) ranges from zero to one because \(|2\eta-1|\in[0,1]\).

Minimizing the Hinge Conditional Risk

The conditional risk is symmetric: replacing \(\eta\) by \(1-\eta\) and \(t\) by \(-t\) leaves \(R_\eta(t)\) unchanged. It is therefore enough to calculate the minima when \(\eta\geq 1/2\). Set \(q=2\eta-1\), so \(q\in[0,1]\) and \(\eta=(1+q)/2\).

On the three score regions, direct substitution into the hinge risk gives

$$ R_\eta(t)= \begin{cases} \eta(1-t), & t\leq -1,\\ 1-qt, & -1\leq t\leq 1,\\ (1-\eta)(1+t), & t\geq 1. \end{cases} $$

For \(t\leq-1\), the first expression decreases as \(t\) increases, since its slope is \(-\eta\). For \(-1\leq t\leq1\), the slope is \(-q\), which is nonpositive. For \(t\geq1\), the last expression is nondecreasing. These facts locate both constrained minima, including the cases \(q=0\) and \(\eta=1\).

Worked Example: Conditional Probability 0.8

Suppose \(P(Y=1\mid X=x)=0.8\). Then \(q=2(0.8)-1=0.6\), and the conditional risk is

$$ R_{0.8}(t)= \begin{cases} 0.8(1-t), & t\leq-1,\\ 1-0.6t, & -1\leq t\leq1,\\ 0.2(1+t), & t\geq1. \end{cases} $$

The correct side is \(t\geq0\). On \([0,1]\), the risk decreases from \(1\) to \(0.4\); on \([1,\infty)\), it increases from \(0.4\). Hence \(H(0.8)=0.4\), attained at \(t=1\). The wrong-side constraint is \(t\leq0\). On \([-1,0]\), the risk decreases to \(1\) at zero, and on \((-\infty,-1]\) its minimum is \(R_{0.8}(-1)=1.6\). Thus \(H^-(0.8)=1\), and the constrained excess is \(1-0.4=0.6=q\).

Theorem: For every \(\eta\in[0,1]\), the unrestricted conditional hinge-risk infimum is \(H(\eta)=1-|2\eta-1|\), and the wrong-side constrained infimum is \(H^-(\eta)=1\). Consequently, \(H^-(\eta)-H(\eta)=|2\eta-1|\).

Proof. First suppose \(\eta\geq1/2\), so \(q=2\eta-1\geq0\). On \([-1,1]\), \(R_\eta(t)=1-qt\), whose minimum is at \(t=1\) when \(q>0\), and is constant when \(q=0\). Its value at \(t=1\) is \(1-q\). For \(t\leq-1\), the risk is decreasing as \(t\) increases, so its minimum on that region is at \(-1\), with value \(2\eta=1+q\). For \(t\geq1\), the risk is nondecreasing and its value at \(1\) is \(2(1-\eta)=1-q\). Therefore \(H(\eta)=1-q\).

Under the wrong-side constraint \(t\leq0\), the middle expression \(1-qt\) is at least \(1\), with value \(1\) at \(t=0\). On \(t\leq-1\), the minimum occurs at \(-1\) and equals \(1+q\), which is also at least \(1\). Hence \(H^-(\eta)=1\). If \(\eta<1/2\), the symmetry \(R_\eta(t)=R_{1-\eta}(-t)\) gives the same formulas with \(q\) replaced by \(|2\eta-1|\), and exchanges the two score sides. Thus the stated identities hold for all \(\eta\in[0,1]\). \(\square\)

The Exact Calibration Function

The theorem reduces the calibration-function calculation to a one-dimensional infimum. At a conditional class probability \(\eta\), the surrogate excess forced by the wrong-side constraint is exactly the conditional classification regret \(q=|2\eta-1|\). Requiring that regret to be at least \(\epsilon\) therefore requires \(q\geq\epsilon\).

Theorem: For \(0\leq\epsilon\leq1\), the hinge loss calibration function is \(\psi(\epsilon)=\epsilon\).

Proof. By the definition and the preceding result,

$$ \psi(\epsilon) =\inf_{\eta:\,|2\eta-1|\geq\epsilon}|2\eta-1| =\inf_{q\in[\epsilon,1]}q =\epsilon. $$

The final infimum is attained: take \(\eta=(1+\epsilon)/2\), for which \(2\eta-1=\epsilon\), and use the boundary score \(t=0\). At this score \(R_\eta(0)=1=H^-(\eta)\), while the unrestricted infimum is \(1-\epsilon\). Their difference is \(\epsilon\). When \(\epsilon=0\), choosing \(\eta=1/2\) gives zero excess, as the formula requires. \(\square\)

This equality also has a useful pointwise interpretation. If a score is on the wrong side at a particular \(x\), then its conditional hinge risk is at least \(H^-(\eta)\), while the best possible conditional hinge risk is \(H(\eta)\). Therefore its conditional surrogate excess is at least \(|2\eta-1|\), exactly the conditional classification regret incurred by choosing the wrong class.

Worked Example: Conditional Probability 0.25

Let \(P(Y=1\mid X=x)=0.25\). Now the more likely label is \(-1\), and \(|2\eta-1|=|0.5-1|=0.5\). By symmetry, a correct-side score is \(t=-1\). Its risk is

$$ R_{0.25}(-1) =0.25(1-(-1))+0.75(1+(-1)) =0.25(2)+0 =0.5. $$

At the boundary \(t=0\), the risk is \(R_{0.25}(0)=0.25+0.75=1\), which is the wrong-side constrained infimum. The difference is \(1-0.5=0.5\), equal to the conditional classification regret. The calculation is the mirror image of the case \(\eta=0.75\) or \(0.8\): changing which label is more probable changes the correct sign, not the size of the calibration gap.

Worked Example: A Calibration Threshold of 0.3

Consider the calibration function at \(\epsilon=0.3\). Any conditional probability satisfying \(|2\eta-1|\geq0.3\) has wrong-side hinge excess at least \(0.3\), by the theorem. Equality is attained at \(\eta=0.65\), because \(2(0.65)-1=0.3\). For this distribution, \(R_{0.65}(t)=1-0.3t\) on \([-1,1]\). The unrestricted minimum is \(R_{0.65}(1)=0.7\), while the wrong-side minimum is \(R_{0.65}(0)=1\). Thus the excess is \(1-0.7=0.3\), confirming \(\psi(0.3)=0.3\).

If instead \(\eta=0.9\), the conditional regret is \(0.8\), so the wrong-side excess is \(0.8\), not \(0.3\). The calibration function takes the smallest excess among all conditional problems whose classification regret is at least the specified threshold.

Why the Linear Calibration Matters

A calibration function relates a conditional classification error to a conditional surrogate excess. For hinge loss, the relation is especially direct: there is no curvature correction or nonlinear transformation in the exact conditional comparison. A wrong-side score at a point with class imbalance \(q\) incurs at least \(q\) excess hinge risk there.

The statement concerns the constrained conditional risk, not the value of the hinge loss at every wrong-side score. Some wrong-side scores have substantially larger excess. For example, when \(\eta=0.8\), the boundary score has excess \(0.6\), while \(t=-1\) has risk \(1.6\) and excess \(1.2\). The calibration function records the smallest possible excess under the constraint, not a claim that all constrained scores attain that minimum.

  • Mistake: Minimize \(R_\eta(t)\) over all \(t\) and call that the wrong-side risk. This gives \(H(\eta)\), which is the unrestricted benchmark, not \(H^-(\eta)\).
  • Correction: Apply the score constraint \(t(2\eta-1)\leq0\) before minimizing. For \(\eta\geq1/2\), this restricts to \(t\leq0\), where the minimum is at the boundary \(t=0\).
  • Mistake: Treat the value \(1\) at the boundary as the unrestricted minimum. When \(\eta>1/2\), the unrestricted minimum is \(1-(2\eta-1)\), attained at \(t=1\).
  • Correction: Subtract the unrestricted infimum from the constrained infimum. The difference is \(1-[1-|2\eta-1|]=|2\eta-1|\).

The boundary convention is important for an exact infimum calculation. If one required a strictly wrong sign, the best value for \(\eta>1/2\) would still be approached as \(t\) increases to zero from below, but it would not be attained. Including \(t=0\) makes the constrained minimum explicit and yields the same infimum. The linear result is specific to the hinge loss; other margin losses require their own conditional-risk minimizations.

Key takeaway: For hinge loss, the unrestricted conditional risk is \(1-|2\eta-1|\), and the minimum risk on the wrong side is \(1\). Their difference is exactly the conditional classification regret, so the calibration function is \(\psi(\epsilon)=\epsilon\) on \([0,1]\).

Check Your Understanding

Use the conditional-risk formulas and the score constraint to answer each question.

  1. For \(\eta=0.7\), calculate the conditional classification regret, the unrestricted hinge-risk infimum, and the wrong-side constrained infimum.
  2. Why is \(t=0\) included in the wrong-side constraint, and what changes if the score must be strictly wrong-signed?
  3. For \(\epsilon=0.6\), give a value of \(\eta\) that attains the infimum defining \(\psi(\epsilon)\), and identify a score attaining the wrong-side risk.
  4. Explain why a wrong-side score can have more than \(|2\eta-1|\) conditional hinge excess even though the calibration function equals \(\epsilon\).
  5. Use the symmetry between \(\eta\) and \(1-\eta\) to state the correct-sign minimizing score when \(\eta=0.2\).
Clinical Biostats