Tutorials › Statistical Learning (Graduate) › Lipschitz Losses and Sensitivity to Predictions

Losses, Risks, and Regret · Tutorial 38 of 989

Lipschitz Losses and Sensitivity to Predictions

Learn to quantify how much a loss, and therefore a risk, can change when a prediction is perturbed.

Beginner 9 min read

What You'll Learn

  • Define a uniform Lipschitz bound for a loss as its prediction changes.
  • Derive the unit sensitivity bound for absolute loss.
  • Verify the Lipschitz constant of the hinge loss for binary labels.
  • Show why clipping a nonnegative Lipschitz loss preserves its bound.
  • Relate pointwise prediction differences to changes in population risk.
  • Distinguish boundedness of a loss from Lipschitz continuity.

Why Prediction Sensitivity Matters

A prediction is often an approximation: a fitted model may be rounded, a numerical algorithm may stop before exact convergence, or two candidate rules may make slightly different predictions for the same case. A useful question is therefore: how much can the loss change when the prediction changes? Lipschitz continuity gives a direct quantitative answer.

The bound concerns the prediction argument of the loss, not how the loss changes with the outcome. It can be used pointwise for a single observation and, with an appropriate integrability condition, to control the difference between population risks. It does not by itself say that a prediction is accurate or that a model has small risk.

Definition and Basic Interpretation

Let \(\mathcal{Y}\) be an outcome space, let \(\mathcal{T}\subseteq\mathbb{R}\) be a prediction domain, and let \(\ell(y,t)\) be a loss for outcome \(y\in\mathcal{Y}\) and prediction \(t\in\mathcal{T}\). The usual distance between two real-valued predictions \(s\) and \(t\) is \(|t-s|\).

Definition: The loss \(\ell\) is L-Lipschitz in its prediction argument on \(\mathcal{T}\) if \(L\geq 0\) and $$ |\ell(y,t)-\ell(y,s)|\leq L|t-s| $$ for every \(y\in\mathcal{Y}\) and every \(s,t\in\mathcal{T}\). The same constant \(L\) must work uniformly over the outcomes and prediction pairs under consideration. The smallest such constant, if it exists, is the Lipschitz constant on that domain.

The absolute value on the left measures the change in loss, regardless of which prediction has the larger loss. For example, a constant \(L=2\) means that changing the prediction by at most \(0.1\) changes the loss by at most \(0.2\), for every outcome covered by the definition. A loss may have a smaller Lipschitz constant on a restricted prediction domain than on all of \(\mathbb{R}\); the domain is part of the claim.

Worked Example: Sensitivity of Absolute Loss

For real outcomes and predictions, consider \(\ell(y,t)=|y-t|\). Compare predictions \(s=2\) and \(t=2.3\) when the observed outcome is \(y=5\).

The two losses are \(|5-2|=3\) and \(|5-2.3|=2.7\). Their absolute difference is \(0.3\), equal to the prediction difference \(|2.3-2|=0.3\). The bound predicts that the loss difference cannot exceed the prediction difference; here it is attained.

For \(y=1\), the losses are \(|1-2|=1\) and \(|1-2.3|=1.3\), again with difference \(0.3\). The direction of change depends on the outcome, but the absolute sensitivity bound does not.

Absolute and Hinge Loss Bounds

For absolute loss, the reverse triangle inequality gives a bound that holds for every real outcome and every pair of real predictions.

Result: The absolute loss \(\ell(y,t)=|y-t|\) is \(1\)-Lipschitz in \(t\) on \(\mathbb{R}\), uniformly over \(y\in\mathbb{R}\).

To see the inequality directly, the triangle inequality gives \(|y-t|\leq |y-s|+|s-t|\), so \(|y-t|-|y-s|\leq |t-s|\). Reversing \(s\) and \(t\) gives \(|y-s|-|y-t|\leq |t-s|\). Together these are exactly \(\big||y-t|-|y-s|\big|\leq |t-s|\).

The hinge loss is used with binary labels \(y\in\{-1,+1\}\) and a real-valued prediction, or score, \(t\). For a real number \(a\), write \([a]_+=\max\{a,0\}\). The hinge loss is \(\ell(y,t)=[1-yt]_+\). Its sensitivity bound follows because taking the positive part cannot increase the distance between two real numbers.

Result: For \(y\in\{-1,+1\}\), the hinge loss \(\ell(y,t)=[1-yt]_+\) is \(1\)-Lipschitz in \(t\) on \(\mathbb{R}\).

For completeness, if \(a\) and \(b\) are both nonnegative, then \(|[a]_+-[b]_+|=|a-b|\); if both are nonpositive, the difference is zero. If, for example, \(a\geq 0\geq b\), then \(|[a]_+-[b]_+|=a\leq a-b=|a-b|\). The case \(b\geq 0\geq a\) is the same with the roles reversed. Thus \(|[a]_+-[b]_+|\leq |a-b|\) in all cases. Apply this with \(a=1-yt\) and \(b=1-ys\):

$$ |\ell(y,t)-\ell(y,s)| \leq |(1-yt)-(1-ys)| =|y|\,|t-s| =|t-s|. $$

The last equality uses the binary-label condition \(|y|=1\). If labels instead had magnitude at most \(M\), the same argument would give a bound \(M|t-s|\). Without a bound on label magnitude, this argument does not yield one uniform finite Lipschitz constant.

Worked Example: Hinge Loss for Two Predictions

Take label \(y=-1\), with predictions \(s=-0.4\) and \(t=-0.1\). The prediction difference is \(|t-s|=0.3\).

At \(s=-0.4\), the margin \(ys=(-1)(-0.4)=0.4\), so the hinge loss is \([1-0.4]_+=0.6\). At \(t=-0.1\), the margin is \(yt=0.1\), so the hinge loss is \([1-0.1]_+=0.9\). The loss difference is \(|0.9-0.6|=0.3\), which meets the \(1\)-Lipschitz bound.

If instead \(s=-2\) and \(t=-2.3\), both margins exceed \(1\), so both hinge losses are zero. The prediction changes by \(0.3\), while the loss changes by zero. Lipschitz continuity gives an upper bound, not a requirement that every prediction change alter the loss.

Clipping a Loss

A common way to bound a nonnegative loss is to cap it at a fixed level \(B>0\). Define the clipped loss by \(\ell_B(y,t)=\min\{\ell(y,t),B\}\). If the original loss is \(L\)-Lipschitz, clipping does not increase its Lipschitz constant.

Result: If \(\ell(y,t)\geq 0\) and \(\ell\) is \(L\)-Lipschitz in \(t\), then \(\ell_B(y,t)=\min\{\ell(y,t),B\}\) is also \(L\)-Lipschitz in \(t\). In addition, \(0\leq\ell_B(y,t)\leq B\).

Here is a proof of the sensitivity claim. For any nonnegative \(u,v\), suppose first that both are at most \(B\), or that both are at least \(B\). In the first case, \(|\min(u,B)-\min(v,B)|=|u-v|\); in the second, it is zero. If \(u\leq B\leq v\), then \(|\min(u,B)-\min(v,B)|=B-u\leq v-u=|v-u|\). The reversed ordering follows by exchanging \(u\) and \(v\). Therefore \(|\min(u,B)-\min(v,B)|\leq |u-v|\) in every case. Substituting \(u=\ell(y,t)\) and \(v=\ell(y,s)\) gives

$$ |\ell_B(y,t)-\ell_B(y,s)| \leq |\ell(y,t)-\ell(y,s)| \leq L|t-s|. $$

This also shows why clipping and Lipschitz continuity are distinct properties: clipping provides a bound on the loss values, while the original Lipschitz property controls how quickly those values can change with the prediction.

Worked Example: Clipped Absolute Loss

Let \(y=3\) and clip absolute loss at \(B=1.5\), so \(\ell_B(y,t)=\min\{|y-t|,1.5\}\). Compare predictions \(t=0\) and \(s=2\).

At \(t=0\), the un-clipped loss is \(|3-0|=3\), so the clipped loss is \(\min\{3,1.5\}=1.5\). At \(s=2\), the un-clipped loss is \(|3-2|=1\), so the clipped loss is \(\min\{1,1.5\}=1\). The prediction difference is \(2\), and the clipped-loss difference is \(0.5\), which is no larger than the absolute-loss bound \(1\cdot 2=2\).

For predictions \(t=0\) and \(s=0.5\), both un-clipped losses exceed \(1.5\): they are \(3\) and \(2.5\). Both clipped losses equal \(1.5\), so the loss difference is zero even though the predictions differ by \(0.5\). The cap creates a flat region in the loss values.

From Prediction Bounds to Risk Bounds

Pointwise sensitivity can control population risk when predictions are random because they depend on the observed case. Let \(Y\) be an outcome and let \(T\) and \(S\) be measurable real-valued predictions for that case. Write \(R(T)=E[\ell(Y,T)]\) and \(R(S)=E[\ell(Y,S)]\), assuming these expectations are finite.

Theorem: Suppose \(\ell\) is \(L\)-Lipschitz in its prediction argument uniformly over outcomes, \(R(T)\) and \(R(S)\) are finite, and \(E[|T-S|]<\infty\). Then $$ |R(T)-R(S)|\leq L E[|T-S|]. $$ If \(|T-S|\leq\delta\) almost surely for some \(\delta\geq0\), it follows that \(|R(T)-R(S)|\leq L\delta\).

To prove the first claim, finiteness of the risks makes their difference equal to the expectation of the difference of the losses. The pointwise Lipschitz condition and the absolute-value inequality for expectations give

$$ \begin{aligned} |R(T)-R(S)| &=|E[\ell(Y,T)-\ell(Y,S)]|\\ &\leq E[|\ell(Y,T)-\ell(Y,S)|]\\ &\leq L E[|T-S|]. \end{aligned} $$

The assumed integrability of \(|T-S|\) ensures the last expectation is finite. If \(|T-S|\leq\delta\) almost surely, monotonicity of expectation gives \(E[|T-S|]\leq\delta\), proving the second claim. \(\square\)

Worked Example: Bounding a Risk Change

Suppose two prediction rules \(T\) and \(S\) use absolute loss, have finite risks, and satisfy \(E[|T-S|]=0.08\). Since absolute loss is \(1\)-Lipschitz, the theorem gives

\(|R(T)-R(S)|\leq 1(0.08)=0.08.\)

Thus their population risks can differ by at most \(0.08\). This does not identify which rule has smaller risk; it limits the size of the difference. If instead the predictions differ by at most \(0.02\) almost surely, the stronger uniform bound is \(|R(T)-R(S)|\leq0.02\).

Common Pitfalls and Use

Lipschitz bounds are useful when translating prediction approximation into loss or risk approximation. For example, if a computation produces predictions close to a target rule on average, a Lipschitz loss turns that closeness into a bound on the corresponding risk difference. The bound can also help separate numerical or approximation error from other sources of statistical error.

  • Using a constant without checking the domain. A bound established on a restricted prediction interval need not hold with the same constant outside it. State the domain and verify the bound there.
  • Forgetting uniformity over outcomes. A prediction-wise bound for each fixed outcome is not enough for a single risk bound if its constant can grow without control across outcomes. The theorem uses one constant that works uniformly.
  • Confusing boundedness with sensitivity. A loss taking values in a bounded interval need not have small changes for small changes in prediction. A range bound and a Lipschitz bound answer different questions.
  • Reading an upper bound as an equality. The change in loss may be much smaller than \(L|t-s|\), or even zero, as in the saturated part of a clipped loss.
  • Ignoring risk assumptions. The risk-difference statement above assumes finite risks. Its proof also uses \(E[|T-S|]<\infty\); without that condition the displayed bound need not be informative.

The main practical step is to identify the prediction argument, specify the outcome and prediction domains, and establish a uniform constant. Once that pointwise inequality is known, the risk bound follows by taking expectations under the stated integrability conditions.

Check Your Understanding

Use the definitions and bounds above to answer the following.

  1. State the definition of an \(L\)-Lipschitz loss in its prediction argument and explain what must be uniform over outcomes.
  2. Why does absolute loss have Lipschitz constant \(1\), and where does the reverse triangle inequality enter the argument?
  3. For hinge loss, what changes in the sensitivity bound if labels satisfy \(|y|\leq M\) rather than being restricted to \(\{-1,+1\}\)?
  4. Explain why clipping a nonnegative \(L\)-Lipschitz loss at a positive cap preserves its Lipschitz constant.
  5. If two rules have \(E[|T-S|]=0.05\) and the loss is \(3\)-Lipschitz, what upper bound does the risk inequality give?
Clinical Biostats