Tutorials › Exam SRM - Statistics for Risk Modeling › Choosing A Boosting Loss For The Outcome

Exam SRM · Boosting Methods · Tutorial 656 of 926

Choosing A Boosting Loss For The Outcome

Choose a boosting loss that matches the response and the quantity the model is meant to estimate, and understand the trade-offs each loss creates.

Advanced 12 min read

What You'll Learn

  • Match squared-error loss to conditional-mean estimation and absolute-error loss to conditional-median estimation.
  • Explain how Huber loss combines quadratic behavior near zero with bounded residual influence in its linear tails.
  • Distinguish exponential-loss classification scores from logistic-loss probabilities.
  • Calculate loss-minimizing constant predictions for a regression sample and a binary-classification group.
  • Identify common errors in coding class labels, interpreting scores, and identifying medians.

Why the Loss Function Is a Modeling Choice

A boosting model is built by adding successive corrections to a current prediction, with each correction directed toward reducing a chosen loss. The loss therefore does more than measure whether predictions are close to observed outcomes: it determines which prediction is optimal for a given response distribution and how strongly different errors affect fitting. Choosing a loss should start with the response type and the quantity the model is intended to estimate.

For a numerical response, squared error emphasizes large residuals, absolute error targets a conditional median, and Huber loss provides a compromise. For a binary response, exponential and logistic losses are classification objectives based on margins, but their scores have different probability interpretations. The calculations below concern the loss objective itself; they do not require a particular tree structure.

Definition: Let \(Y\) be a response and \(F(X)\) a prediction based on predictors \(X\). A loss \(L(Y,F(X))\) assigns a nonnegative penalty to the prediction and response. The conditional risk at predictor value \(x\) is \(E[L(Y,a)\mid X=x]\), viewed as a function of candidate prediction \(a\). A loss's target is a value of \(a\) that minimizes this conditional risk. In a data set, boosting instead minimizes the corresponding empirical sum or average of losses.

Losses for a Numerical Response

Write the residual as \(r=y-a\), where \(y\) is an observed numerical response and \(a\) is a candidate prediction. A factor of one-half is often included in squared error because it simplifies derivatives; multiplying a loss by a positive constant does not change its minimizer.

Definition: The squared-error, absolute-error, and Huber losses are, respectively,
$$ L_{\mathrm{sq}}(y,a)=\frac{1}{2}(y-a)^2,\qquad L_{\mathrm{abs}}(y,a)=|y-a|, $$
and
$$ L_{\mathrm{H},\delta}(y,a)= \begin{cases} \frac{1}{2}(y-a)^2, & |y-a|\leq \delta,\\ \delta\left(|y-a|-\frac{1}{2}\delta\right), & |y-a|>\delta, \end{cases} \qquad \delta>0. $$
The parameter \(\delta\) is expressed in the units of the response. Huber loss is quadratic for small residuals and linear for large residuals.

Under squared error, the conditional-risk minimizer is the conditional mean, provided \(E[Y^2\mid X=x]\) is finite. To see why, expand the conditional risk:

$$ E\left[\frac{1}{2}(Y-a)^2\mid X=x\right] =\frac{1}{2}E[Y^2\mid X=x]-aE[Y\mid X=x]+\frac{a^2}{2}. $$

Differentiating with respect to \(a\) gives \(a-E[Y\mid X=x]\); setting this equal to zero gives \(a=E[Y\mid X=x]\). The second derivative is \(1\), so this is the unique minimizer when the conditional mean exists. This is a statement about the target of the loss, not a claim that the conditional distribution must be normal.

For absolute error, the conditional-risk minimizers are conditional medians. Specifically, a value \(a\) is a median if both \(P(Y\leq a\mid X=x)\geq 1/2\) and \(P(Y\geq a\mid X=x)\geq 1/2\). There can be one median or an interval of medians. The subgradient of the absolute loss with respect to \(a\) is \(-1\) when \(y>a\), \(1\) when \(y<a\), and the interval \([-1,1]\) when \(y=a\). A conditional-risk minimum occurs when the resulting expected subgradient includes zero, which gives precisely the median condition.

Worked Example: Mean and Median Targets for a Skewed Loss

A hypothetical claim-severity segment has the following conditional distribution, with amounts measured in thousands of dollars: \(Y=1\) with probability \(0.4\), \(Y=3\) with probability \(0.4\), and \(Y=8\) with probability \(0.2\). Find the squared-error target and all absolute-error targets. Explain which loss is more directly focused on a typical claim amount.

Method and squared-error calculation. The squared-error target is the conditional mean. Its value is

$$ E[Y]=0.4(1)+0.4(3)+0.2(8)=0.4+1.2+1.6=3.2. $$

Thus the squared-error target is \(3.2\) thousand dollars. As a check on the calculation, the probabilities sum to \(0.4+0.4+0.2=1\), and the weighted outcomes sum to \(3.2\).

Method and absolute-error calculation. A median must have at least half the probability at or below it and at least half at or above it. At \(a=3\),

$$ P(Y\leq 3)=0.4+0.4=0.8,\qquad P(Y\geq 3)=0.4+0.2=0.6. $$

Both probabilities are at least \(0.5\), so \(3\) is a median. For any \(a\) strictly between \(1\) and \(3\), \(P(Y\leq a)=0.4<0.5\); for any \(a\) strictly between \(3\) and \(8\), \(P(Y\geq a)=0.2<0.5\). Values below \(1\) or above \(8\) also fail a median condition. The only absolute-error target is therefore \(3\) thousand dollars.

The absolute-error target is the median, \(3\), while the squared-error target is the mean, \(3.2\). The mean is pulled upward by the larger outcome, as intended by squared error's greater penalty for large residuals. The common mistake is to call every value from \(1\) to \(3\) a median: values \(a<3\) in that interval have only \(0.4\) probability at or below them, so they fail the median condition.

Huber Loss: A Middle Ground

Huber loss retains a quadratic penalty close to the prediction, but its penalty grows linearly once the residual magnitude exceeds \(\delta\). Its derivative with respect to the prediction, for a residual not exactly at the transition, is the negative of the clipped residual:

$$ \frac{\partial L_{\mathrm{H},\delta}(y,a)}{\partial a} = \begin{cases} -(y-a), & |y-a|\leq\delta,\\ -\delta\,\operatorname{sign}(y-a), & |y-a|>\delta. \end{cases} $$

The derivative magnitude is at most \(\delta\). Consequently, a very large residual does not keep increasing its individual gradient contribution, unlike under squared error. The conditional Huber target minimizes expected Huber loss; it is generally neither the conditional mean nor the conditional median. Its value depends on \(\delta\) and the conditional distribution.

Worked Example: Finding a Huber Target in the Presence of an Outlier

Four hypothetical numerical observations in a leaf are \(0,0,0,4\). Use Huber loss with \(\delta=1\) to find the loss-minimizing constant prediction. Compare it with the squared-error and absolute-error targets.

Method. Since the empirical Huber objective is convex, a prediction minimizes it when the sum of its derivatives with respect to the prediction is zero, allowing a subgradient at a join. Equivalently, sum the clipped residuals \(y-a\) and set the sum to zero.

The squared-error target is the arithmetic mean:

$$ \bar{y}=\frac{0+0+0+4}{4}=1. $$

The absolute-error target is the sample median. The two middle ordered observations are both zero, so the median is \(0\). For the Huber target, consider \(0<a<1\). The first three residuals are \(-a\), each within the threshold, while the fourth residual is \(4-a>1\), so it is clipped to \(1\). The sum of clipped residuals is

$$ (-a)+(-a)+(-a)+1=1-3a. $$

Setting this equal to zero gives \(a=1/3\), which is indeed in the interval assumed. The objective confirms the result. At \(a=1/3\), the first three losses sum to \(3\cdot\frac{1}{2}(1/3)^2=1/6\); the last residual is \(11/3\), giving loss \(11/3-1/2=19/6\). The total is \(1/6+19/6=10/3\). At \(a=0\), the total is \(0+0+0+(4-1/2)=7/2\), which is larger. Convexity and the zero derivative establish the minimum at \(1/3\).

The three targets are \(1\) for squared error, \(0\) for absolute error, and \(1/3\) for Huber loss. Huber moves away from the median because small residuals still receive quadratic treatment, but it is less pulled by the outlier than the mean. This example uses a continuous prediction within the observed range; a constant prediction need not be one of the observed values.

Losses for Binary Classification

For binary classification, encode the observed class as \(Y\in\{-1,+1\}\), and let \(F(X)\) be a real-valued score. The signed margin is \(YF(X)\): a positive margin means the score has the correct sign, while a negative margin means it has the wrong sign. Exponential and logistic losses penalize margins rather than directly minimizing the number of misclassified observations.

Definition: For \(Y\in\{-1,+1\}\), exponential loss and logistic loss may be written as
$$ L_{\exp}(Y,F)=\exp(-YF),\qquad L_{\log}(Y,F)=\log\left(1+\exp(-YF)\right). $$
Exponential loss is the objective used in AdaBoost. Under the stated logistic convention, the class-\(+1\) probability associated with score \(F\) is \(p=1/(1+\exp(-F))\); logistic loss is binary cross-entropy expressed through the signed label.

The two losses behave differently on confidently wrong cases. If \(YF\) is very negative, exponential loss and the magnitude of its score derivative grow rapidly. Logistic loss also penalizes a confidently wrong prediction, but its derivative magnitude with respect to \(F\) is at most \(1\). If \(YF\) is large and positive, both losses become small. Logistic loss has a direct probability interpretation under the stated coding; an exponential-loss score is not, by itself, a probability.

Worked Example: Comparing Exponential and Logistic Classification Scores

A hypothetical leaf contains three positive cases and one negative case. Treat the score \(F\) as constant within the leaf, encode positive as \(+1\) and negative as \(-1\), and find the constant score minimizing each loss. Then interpret the logistic score as a probability.

Exponential-loss method. The total loss is

$$ Q_{\exp}(F)=3\exp(-F)+\exp(F). $$

Differentiate and set the derivative to zero:

$$ Q'_{\exp}(F)=-3\exp(-F)+\exp(F)=0 \quad\Longrightarrow\quad \exp(2F)=3 \quad\Longrightarrow\quad F=\frac{1}{2}\log 3\approx 0.5493. $$

The second derivative \(3\exp(-F)+\exp(F)\) is positive, so this is the minimum. At this score, the three positive-case losses sum to \(3/\sqrt{3}=\sqrt{3}\), and the negative-case loss is \(\sqrt{3}\). The total is \(2\sqrt{3}\approx3.4641\).

Logistic-loss method. Let \(p=1/(1+\exp(-F))\). A positive observation contributes \(-\log p\); a negative observation contributes \(-\log(1-p)\). Thus the total is

$$ Q_{\log}(p)=-3\log p-\log(1-p),\qquad 0<p<1. $$

Differentiating gives \(-3/p+1/(1-p)=0\), so \(p=3(1-p)\), \(4p=3\), and \(p=3/4\). The corresponding score is \(F=\log(p/(1-p))=\log 3\approx1.0986\). Its total loss is \(-3\log(3/4)-\log(1/4)=3\log(4/3)+\log 4\approx2.2493\). This is the minimum because the second derivative of \(Q_{\log}(p)\) is \(3/p^2+1/(1-p)^2>0\).

The logistic fit yields the group proportion \(0.75\) as its probability estimate. The exponential fit yields score \(\frac{1}{2}\log 3\), not a probability; applying the logistic transformation to that score would give a different value. The common error is to treat the two loss conventions as though their scores had identical probability scales.

Choosing Among the Losses

The response type narrows the choices, but the modeling objective determines the final choice. A loss should be selected based on the prediction target and error behavior that matter for the application, not simply because it is available in a particular boosting implementation.

LossTypical response and targetImportant consequence
Squared errorNumerical response; conditional meanLarge residuals have disproportionately large penalties and gradients.
Absolute errorNumerical response; conditional medianResidual penalty grows linearly; individual slope magnitude is bounded by 1.
Huber lossNumerical response; conditional Huber locationQuadratic near zero and linear beyond the response-scale threshold \(\delta\).
Exponential lossBinary labels coded as \(-1,+1\); margin-based classificationStrongly emphasizes confidently wrong cases; raw score is not a probability.
Logistic lossBinary response; probability estimation and classificationPenalizes wrong margins with bounded score gradient and has a direct probability interpretation.

For example, if the required numerical prediction is an expected claim amount, squared error's conditional-mean target is aligned with that objective. If the aim is a typical amount that is less sensitive to extreme observations, absolute error or Huber loss may be more appropriate, while recognizing that the Huber target depends on its threshold. For a binary event where estimated probabilities are needed, logistic loss directly matches probability estimation under its model convention. Exponential loss is a natural choice when the goal is margin-based boosting as in AdaBoost, but its scores should not be reported as probabilities without a justified probability interpretation or a separate calibration procedure.

These choices do not imply that one loss is universally best. Different losses answer different questions, and they can produce different predictions from the same data. The choice should be stated alongside the response coding, units, and intended interpretation. This topic is aligned with the SOA Exam SRM (Statistics for Risk Modeling) syllabus.

Common Mistakes to Avoid

  • Equating the mean with the median. Squared error targets a conditional mean; absolute error targets a conditional median. A skewed or discrete distribution can make them differ.
  • Declaring a whole interval to be medians without checking both conditions. A candidate median must have at least one-half of the probability on each side, counting probability at the candidate appropriately.
  • Calling Huber loss an absolute-error loss. Huber is quadratic for residuals up to \(\delta\), and only linear beyond it. Its target generally equals neither the mean nor the median.
  • Ignoring the units of \(\delta\). If the response is measured in thousands of dollars, \(\delta\) is also in thousands of dollars; changing response scale without changing \(\delta\) changes the loss.
  • Using exponential or logistic loss with inconsistent labels. The formulas shown require labels coded as \(-1,+1\). If labels are instead coded \(0,1\), use the corresponding binary cross-entropy expression rather than substituting those labels into the signed-margin formulas.
  • Interpreting every classification score as a probability. Under the convention here, logistic scores map to probabilities by the logistic function. Exponential-loss scores do not have that direct interpretation.
Key takeaway: Match the loss to the target: squared error for conditional means, absolute error for conditional medians, Huber for a threshold-dependent compromise, exponential loss for margin-based boosting, and logistic loss when probability estimation is part of the objective. Always verify label coding and interpret scores according to the loss actually used.

Check Your Understanding

For each problem, identify the loss target or calculate the requested quantity before checking the answer.

  1. A numerical response takes values \(2\) and \(6\) with probabilities \(0.7\) and \(0.3\), conditional on a fixed predictor value. Find the squared-error target and state whether \(2\) is a median. (Answer: Mean \(=3.2\); \(2\) is a median.)
  2. Four numerical observations are \(1,1,5,9\). Find the squared-error and absolute-error constant targets. (Answer: Squared-error target \(=4\); absolute-error targets are all values in \([1,5]\).)
  3. For observations \(0,0,2\), find the Huber-loss target when \(\delta=1\). (Answer: \(0.5\).)
  4. A binary group has two positive and two negative labels. Under logistic loss with labels \(-1,+1\), find the minimizing probability and score. (Answer: Probability \(=0.5\); score \(F=0\).)
  5. A binary group has four positive cases and one negative case. Under exponential loss \(\exp(-YF)\), find the minimizing constant score and the minimum total loss. (Answer: \(F=\frac{1}{2}\log 4=\log 2\approx0.6931\); minimum total loss \(=4e^{-F}+e^F=4\).)
Clinical Biostats