Tutorials › Statistical Learning (Graduate) › The Derivative Test for Convex Margin Calibration

Surrogate Losses and Calibration · Tutorial 521 of 989

The Derivative Test for Convex Margin Calibration

Learn why a convex margin loss is classification-calibrated precisely when its derivative at zero is strictly negative.

Advanced 10 min read

What You'll Learn

  • Define classification calibration using the conditional surrogate risk and the wrong-sign score constraint.
  • Derive the conditional-risk derivative at a zero score.
  • Prove both directions of the derivative-at-zero criterion for convex margin losses.
  • Interpret a negative, zero, or positive loss derivative at the decision boundary.
  • Check the criterion in hinge, logistic, quadratic, and increasing-loss examples.

Why the Slope at Zero Matters

A margin loss evaluates a score through its signed margin: a large positive margin is intended to indicate a confident correct classification, while a negative margin indicates a score pointing the wrong way. The score zero is the decision boundary. For a convex loss, the slope at that boundary determines whether a small move toward the correct side can lower conditional surrogate risk when the class probabilities are imbalanced.

The derivative criterion is sharp: within the class of convex margin losses differentiable at zero, classification calibration holds exactly when the loss is decreasing there. The proof compares the best conditional risk among scores with the wrong sign to the best risk over all scores. Convexity turns the local slope at zero into a global comparison on each half-line.

Conditional Risk and Calibration

Let \(Y\in\{-1,+1\}\), let \(t\in\mathbb{R}\) be a real-valued score, and let \(\phi:\mathbb{R}\to[0,\infty)\) be a margin loss. Given a feature value, write \(\eta=P(Y=+1\mid X)\). For a fixed \(\eta\), the conditional surrogate risk at score \(t\) is

$$ C_\eta(t)=\eta\phi(t)+(1-\eta)\phi(-t). $$

The first term is the loss when \(Y=+1\), and the second is the loss when \(Y=-1\). If \(\eta>1/2\), the Bayes-optimal class is \(+1\), so a score \(t\leq 0\) has the wrong sign or is tied at zero. If \(\eta<1/2\), a score \(t\geq 0\) has the wrong sign or is tied. The tie is included in the wrong-sign constraint in the definition below.

Definition: A margin loss \(\phi\) is classification-calibrated if, for every \(\eta\in[0,1]\) with \(\eta\neq 1/2\), the infimum of \(C_\eta(t)\) over wrong-sign scores is strictly larger than its unrestricted infimum. Explicitly, $$ \inf_{t\leq 0}C_\eta(t)>\inf_{t\in\mathbb{R}}C_\eta(t)\quad\text{if }\eta>1/2, \qquad \inf_{t\geq 0}C_\eta(t)>\inf_{t\in\mathbb{R}}C_\eta(t)\quad\text{if }\eta<1/2. $$

The condition concerns the conditional risk at every non-tied class probability, not just one data distribution or one chosen score. It does not require the unrestricted infimum to be attained. Using infima makes the definition applicable even when a loss has no finite conditional minimizer.

The Derivative Test

Assume throughout the theorem that \(\phi:\mathbb{R}\to[0,\infty)\) is convex and differentiable at zero. Since \(C_\eta\) is a nonnegative weighted sum of convex functions, it is convex. Differentiating at zero gives

$$ C_\eta'(0) =\eta\phi'(0)-(1-\eta)\phi'(0) =(2\eta-1)\phi'(0). $$
Theorem: A convex margin loss \(\phi\), differentiable at zero, is classification-calibrated if and only if \(\phi'(0)<0\).

We use the supporting-line inequality for a convex function \(g\) differentiable at zero: \(g(t)\geq g(0)+g'(0)t\) for every real \(t\). To see why it holds, convexity makes the slope of a secant from zero to \(t>0\) at least the right derivative at zero; for \(t<0\), the secant slope is at most the left derivative. Rearranging either inequality gives the stated bound.

Proof: A Negative Derivative Is Sufficient

Suppose \(\phi'(0)<0\). First let \(\eta>1/2\). Then \(C_\eta'(0)=(2\eta-1)\phi'(0)<0\). For every wrong-sign score \(t\leq 0\), the supporting-line inequality gives

$$ C_\eta(t)\geq C_\eta(0)+C_\eta'(0)t\geq C_\eta(0), $$

because both \(C_\eta'(0)\) and \(t\) are nonpositive. Differentiability and \(C_\eta'(0)<0\) also imply that for some sufficiently small \(\epsilon>0\), \(C_\eta(\epsilon)<C_\eta(0)\): the difference quotient \([C_\eta(\epsilon)-C_\eta(0)]/\epsilon\) is negative for all sufficiently small positive \(\epsilon\). Therefore

$$ \inf_{t\leq 0}C_\eta(t)\geq C_\eta(0)>C_\eta(\epsilon)\geq\inf_{t\in\mathbb{R}}C_\eta(t). $$

For \(\eta<1/2\), \(C_\eta'(0)>0\). For every wrong-sign score \(t\geq 0\), the supporting-line bound gives \(C_\eta(t)\geq C_\eta(0)\). Differentiability now supplies a sufficiently small \(\epsilon<0\) such that \(C_\eta(\epsilon)<C_\eta(0)\). Thus the wrong-sign infimum is again strictly above the unrestricted infimum. This proves calibration for every \(\eta\neq 1/2\). \(\square\)

Proof: A Nonnegative Derivative Is Necessary for Failure

Now suppose \(\phi'(0)\geq 0\). It is enough to consider \(\eta=3/4\), for which the Bayes-optimal sign is positive and the wrong-sign scores satisfy \(t\leq 0\). Here \(C_\eta'(0)=\phi'(0)/2\geq 0\). For every \(t\geq 0\), convexity gives

$$ C_\eta(t)\geq C_\eta(0)+C_\eta'(0)t\geq C_\eta(0). $$

The wrong-sign set \(t\leq 0\) contains zero, so its infimum \(A=\inf_{t\leq 0}C_\eta(t)\) satisfies \(A\leq C_\eta(0)\). Meanwhile, every score \(t>0\) has risk at least \(C_\eta(0)\), and hence at least \(A\). Thus no score on the positive half-line can have risk below \(A\); taking the infimum over all real scores gives

$$ \inf_{t\in\mathbb{R}}C_\eta(t)=\inf_{t\leq 0}C_\eta(t). $$

The required strict inequality fails at \(\eta=3/4\). Therefore a convex margin loss with nonnegative derivative at zero is not classification-calibrated. Together, the two directions prove the criterion. \(\square\)

Worked Consequences of the Criterion

Worked Example: Hinge Loss

Take \(\phi(u)=(1-u)_+=\max(1-u,0)\). At zero, \(\phi(u)=1-u\) in a neighborhood of zero, so \(\phi'(0)=-1<0\). The theorem therefore says the hinge loss is classification-calibrated.

The conditional risks at \(\eta=3/4\) can also be checked directly. For \(-1\leq t\leq 1\),

$$ C_{3/4}(t)=\tfrac34(1-t)+\tfrac14(1+t)=1-\tfrac12t. $$

This is minimized on that interval at \(t=1\), with value \(1/2\). For \(t\geq 1\), the risk is \(\tfrac14(1+t)\), whose minimum is \(1/2\) at \(t=1\). For \(t\leq-1\), it is \(\tfrac34(1-t)\), whose minimum on that region is \(3/2\) at \(t=-1\). Hence the unrestricted infimum is \(1/2\). On the wrong-sign region, the middle-interval risk is minimized at \(t=0\), with value \(1\), and the \(t\leq-1\) risk is at least \(3/2\). The wrong-sign infimum is \(1>1/2\), as required.

Worked Example: Logistic Loss

Let \(\phi(u)=\log(1+e^{-u})\). This loss is convex, and

$$ \phi'(u)=-\frac{1}{1+e^u}, \qquad \phi'(0)=-\tfrac12<0. $$

It is therefore classification-calibrated. For a numerical check, set \(\eta=4/5\). Differentiating the conditional risk gives

$$ C_{4/5}'(t)=\frac{(1/5)e^t-4/5}{1+e^t}, $$

which vanishes at \(e^t=4\), or \(t=\log 4>0\). The conditional risk there is

$$ C_{4/5}(\log 4) =\tfrac45\log(5/4)+\tfrac15\log 5 \approx 0.5004. $$

At zero the risk is \(C_{4/5}(0)=\log 2\approx0.6931\). Convexity and \(C_{4/5}'(0)=-3/10\) imply \(C_{4/5}(t)\geq C_{4/5}(0)\) for \(t\leq0\). Thus wrong-sign scores cannot attain the lower risk available at the positive score \(\log 4\).

Worked Example: A Convex Loss With Zero Slope

Consider \(\phi(u)=u^2\), which is convex and nonnegative with \(\phi'(0)=0\). At \(\eta=3/4\),

$$ C_{3/4}(t)=\tfrac34t^2+\tfrac14(-t)^2=t^2. $$

Its unrestricted infimum is zero at \(t=0\). The wrong-sign region \(t\leq0\) also contains zero, so its infimum is zero as well. The strict inequality in the definition fails. A zero slope is not enough: despite convexity, this loss does not distinguish the Bayes sign through a strict conditional-risk improvement.

Worked Example: A Convex Loss With Positive Slope

The increasing loss \(\phi(u)=e^u\) is convex and has \(\phi'(0)=1>0\), so the theorem predicts failure. At \(\eta=3/4\),

$$ C_{3/4}(t)=\tfrac34e^t+\tfrac14e^{-t}. $$

Differentiation gives \(C_{3/4}'(t)=\tfrac34e^t-\tfrac14e^{-t}\), which is zero when \(e^{2t}=1/3\). Thus the global minimizer is \(t=-\tfrac12\log 3<0\), which has the wrong sign. Substitution yields

$$ C_{3/4}\!\left(-\tfrac12\log 3\right) =\tfrac{3}{4\sqrt3}+\tfrac{\sqrt3}{4} =\tfrac{\sqrt3}{2}. $$

This minimizer already lies in the wrong-sign region, so the constrained and unrestricted infima are equal. The loss rewards a score in the direction opposite to the more probable class.

Interpretation and a Common Pitfall

At a zero score, the conditional-risk slope is the product \((2\eta-1)\phi'(0)\). The factor \(2\eta-1\) indicates which class is more probable. A strictly negative \(\phi'(0)\) makes the conditional risk slope point toward the Bayes-optimal side: to the right when \(\eta>1/2\), and to the left when \(\eta<1/2\). Convexity then ensures that every score on the wrong side has risk at least as large as the risk at zero, while a nearby score on the correct side has strictly lower risk.

Common mistake: It is tempting to conclude that any convex loss is calibrated because convexity gives a well-behaved risk minimization problem. Convexity alone does not determine which sign the minimizer favors. The loss \(e^u\) is convex, but its positive derivative at zero makes the risk decrease toward a wrong-sign score for \(\eta>1/2\). The correction is to check both hypotheses: convexity supplies the global supporting-line comparison, while the strict negative derivative supplies the correct direction and strict improvement. A derivative of zero gives no strict separation, as the squared-loss example demonstrates.

The theorem is specifically a test for convex margin losses differentiable at zero. Differentiability at zero is part of its hypotheses; the derivative criterion should not be applied without checking that condition. The result answers whether the conditional surrogate optimum distinguishes the Bayes sign. It does not by itself state a rate at which surrogate excess risk controls classification regret.

Check Your Understanding

Use the conditional-risk definition and the derivative test to answer the following.

  1. For \(\phi(u)=(1-u)^2\), calculate \(\phi'(0)\) and decide whether the loss is classification-calibrated.
  2. Why does a strictly negative conditional-risk derivative at zero imply that some small positive score has lower risk when \(\eta>1/2\)?
  3. In the necessity proof, why is it sufficient to show failure at \(\eta=3/4\)?
  4. For a convex differentiable margin loss with \(\phi'(0)=0\), what does convexity imply about \(C_\eta(t)\) relative to \(C_\eta(0)\) on the positive half-line?
  5. Explain why convexity without a negative derivative at zero does not guarantee classification calibration.
Clinical Biostats