Tutorials › Regression Analysis (Undergraduate) › Matching Curve Selection to Prediction Loss

Choosing and Explaining Nonlinear Forms · Tutorial 479 of 991

Matching Curve Selection to Prediction Loss

Choose a nonlinear curve by deciding which prediction mistakes matter most, then evaluating candidate predictions with a loss measure that represents those consequences.

Advanced 12 min read

What You'll Learn

  • Define prediction error and loss for a candidate nonlinear curve
  • Distinguish mean absolute error, mean squared error, and root mean squared error
  • Explain why squared loss gives relatively more influence to large errors
  • Build a loss that penalizes underprediction and overprediction differently
  • Weight prediction errors to reflect the intended deployment population
  • State what a selected curve does and does not establish

Why the Error Measure Matters

Two nonlinear curves can make different kinds of mistakes. One may be close to the observed outcomes for most cases but miss a few by a wide margin. Another may make moderate errors consistently. Which curve is preferable depends not only on how well each fits the data, but on what those prediction mistakes mean in the application.

For example, when forecasting a service time, a large overprediction may waste staff capacity, while a large underprediction may leave people waiting without help. Treating the two errors as equally costly may not suit that task. A curve-selection decision is therefore incomplete until the prediction loss—the numerical penalty assigned to prediction errors—has been chosen and explained.

This tutorial focuses on matching that loss to the prediction task. It does not make one loss universally best. Instead, it shows how to compare candidate curves under a clearly stated measure and how to explain the limits of the resulting choice.

Prediction Errors and Loss

Suppose candidate curve \(m\) gives prediction \(\hat{y}_{mi}\) for case \(i\), whose observed outcome is \(y_i\). Define its prediction error as observed minus predicted:

$$ e_{mi}=y_i-\hat{y}_{mi}. $$

With this convention, \(e_{mi}>0\) means the curve underpredicts, and \(e_{mi}<0\) means it overpredicts. A loss function \(L(e)\) assigns a nonnegative penalty to an error. A common way to summarize performance over \(n\) validation cases is the mean loss:

$$ \overline{L}_m=\frac{1}{n}\sum_{i=1}^{n} L(e_{mi}). $$

A smaller mean loss indicates better performance under that particular loss function and evaluation set. For the comparison to be meaningful, every candidate should be evaluated on the same cases, using the same recorded outcome and loss definition. The validation outcomes should not have been used to fit or tune the candidate curves being compared. The cases should also represent, or be appropriately adjusted to reflect, the situations in which predictions will be used.

Definition: A prediction loss is a rule that assigns a penalty to the difference between an observed outcome and its prediction. A mean prediction loss is the average penalty over the cases being evaluated. Loss is chosen to represent the consequences of errors in the application; it is not determined by the curve alone.

The standard summaries below require no normality assumption simply to calculate them. Their practical interpretation does depend on using comparable cases and a sensible outcome scale. As with any out-of-sample comparison, a low score on one validation set does not guarantee the same ranking on every future set.

Absolute and Squared Error

Two widely used loss functions are absolute error and squared error. Their averages are called mean absolute error and mean squared error. Root mean squared error is the square root of mean squared error.

$$ \operatorname{MAE}_m=\frac{1}{n}\sum_{i=1}^{n}|e_{mi}|,\qquad \operatorname{MSE}_m=\frac{1}{n}\sum_{i=1}^{n}e_{mi}^{2},\qquad \operatorname{RMSE}_m=\sqrt{\operatorname{MSE}_m}. $$

MAE reports a typical absolute error in the same units as the outcome. MSE is in squared outcome units, so it is less directly interpretable in context. RMSE returns to the outcome's units. For a fixed set of predictions, RMSE and MSE always rank candidate curves the same way: taking a square root preserves the ordering of nonnegative numbers.

Squared error gives relatively more influence to a large error than absolute error does. For two positive error magnitudes \(a>b\), their squared-loss ratio is \(a^2/b^2=(a/b)^2\), rather than the absolute-loss ratio \(a/b\). This makes a few large misses more influential in the squared-error average. It does not mean that squared error is always the right choice: that influence is desirable only when large errors should carry especially strong penalties.

A useful algebraic identity is \(a^2-b^2=(a-b)(a+b)\). For positive numerical magnitudes, this difference is greater than \(a-b\) only when \(a+b>1\); it is not a general inequality. Moreover, squared error and absolute error have different units, so directly comparing their numerical values is not a meaningful way to choose between them. The relevant point is the way each loss responds to error magnitudes, not a universal numerical comparison between the two scales.

Worked Example: A Few Large Errors or Many Moderate Ones?

Suppose two hypothetical nonlinear curves predict service time in minutes for the same four validation cases. The observed times are 20, 20, 20, and 20 minutes. Curve A predicts 20, 20, 20, and 24 minutes; curve B predicts 21.2 minutes for each case. Compare MAE and RMSE.

For curve A, the errors \(y_i-\hat{y}_{Ai}\) are \(0,0,0,-4\) minutes. Therefore:

$$ \operatorname{MAE}_A=\frac{|0|+|0|+|0|+|-4|}{4} =\frac{4}{4}=1\text{ minute}, $$
$$ \operatorname{MSE}_A=\frac{0^2+0^2+0^2+(-4)^2}{4} =\frac{16}{4}=4\text{ minutes}^2, \qquad \operatorname{RMSE}_A=\sqrt{4}=2\text{ minutes}. $$

For curve B, all four errors are \(20-21.2=-1.2\) minutes. Thus:

$$ \operatorname{MAE}_B=\frac{4(1.2)}{4}=1.2\text{ minutes}, \qquad \operatorname{MSE}_B=\frac{4(1.2^2)}{4}=1.44\text{ minutes}^2, \qquad \operatorname{RMSE}_B=\sqrt{1.44}=1.2\text{ minutes}. $$

By MAE, curve A is preferred: its mean absolute error is 1 minute rather than 1.2 minutes. By RMSE, curve B is preferred: its RMSE is 1.2 minutes rather than 2 minutes. These rankings differ because curve A has one larger miss, which has more influence under squared loss. Neither ranking is automatically correct; the application determines whether the occasional 4-minute error deserves that extra penalty.

When the Direction of Error Matters

Absolute and squared loss treat overprediction and underprediction symmetrically: errors of equal magnitude receive equal penalties. In some applications, the consequences are asymmetric. A staffing forecast that is too low might leave a service understaffed, while a forecast that is too high might mainly create modest idle capacity.

One simple asymmetric loss assigns a cost per unit of underprediction and a different cost per unit of overprediction. With \(e=y-\hat{y}\), positive errors are underpredictions and negative errors are overpredictions. If the underprediction cost is \(c_u\) per outcome unit and the overprediction cost is \(c_o\), define:

$$ L(e)=c_u\max(e,0)+c_o\max(-e,0). $$

Both cost rates are nonnegative. When \(e>0\), this gives \(L(e)=c_u e\); when \(e<0\), it gives \(L(e)=c_o|e|\). The values of \(c_u\) and \(c_o\) should reflect the task and be stated explicitly. If they are merely chosen after seeing which curve wins, the comparison can be misleading.

Worked Example: Penalizing Underprediction More Heavily

Consider three hypothetical forecasts of service delay, measured in hours. On the same three validation cases, curve A has errors \(2,0,0\) hours, while curve B has errors \(-1,-1,-1\) hours. Suppose, for this illustration, that each hour of underprediction carries 4 cost points and each hour of overprediction carries 1 cost point.

With ordinary MAE, curve A has:

$$ \operatorname{MAE}_A=\frac{|2|+|0|+|0|}{3} =\frac{2}{3}\approx0.667\text{ hours}. $$

Curve B has:

$$ \operatorname{MAE}_B=\frac{|-1|+|-1|+|-1|}{3} =\frac{3}{3}=1\text{ hour}. $$

Ordinary MAE therefore prefers curve A. Under the specified asymmetric loss, curve A's total cost is \(4(2)+0+0=8\) cost points, giving mean cost \(8/3\approx2.67\) cost points per forecast. Curve B overpredicts by 1 hour in each case, so its total cost is \(1(1)+1(1)+1(1)=3\) cost points, giving mean cost \(3/3=1\) cost point per forecast. Under this loss, curve B is preferred.

The preference changes because the application assigns greater cost to underprediction. The conclusion is conditional: curve B has the lower mean cost for these cases under the stated cost rates, not necessarily for other cases or a different cost structure.

Weighting Cases to Match Intended Use

A validation set may not contain cases in the proportions expected during actual use. For instance, a balanced set of routine and severe cases may be useful for studying both types, even though severe cases are rare in deployment. An unweighted average then gives the two types equal influence, which may not represent the average loss expected in use.

If group \(g\) makes up a proportion \(w_g\) of intended predictions, with \(w_g\geq0\) and \(\sum_g w_g=1\), one can average the mean loss within each group using those proportions:

$$ \overline{L}_{m,\mathrm{weighted}} =\sum_g w_g\overline{L}_{mg}. $$

Here \(\overline{L}_{mg}\) is candidate \(m\)'s mean loss among validation cases in group \(g\). The group proportions must come from a defensible description of intended use, not from whichever weights produce a preferred result. This calculation assumes the validation cases give relevant information about candidate performance within each group and that the chosen deployment proportions are appropriate.

Worked Example: Reflecting the Deployment Mix

Suppose a hypothetical validation set includes equal numbers of routine and severe service cases, but the intended deployment population is expected to be 90% routine and 10% severe. Compare two candidate curves using absolute error in hours. Curve A's mean absolute errors are 1 hour for routine cases and 8 hours for severe cases. Curve B's are 2 hours in each group.

On the equal-group validation set, the unweighted averages of the two group means are:

$$ \overline{L}_{A,\mathrm{unweighted}}=\frac{1+8}{2}=4.5\text{ hours}, \qquad \overline{L}_{B,\mathrm{unweighted}}=\frac{2+2}{2}=2\text{ hours}. $$

That comparison prefers curve B. To reflect the stated deployment mix, use weights \(0.9\) and \(0.1\):

$$ \overline{L}_{A,\mathrm{weighted}}=0.9(1)+0.1(8)=0.9+0.8=1.7\text{ hours}, $$
$$ \overline{L}_{B,\mathrm{weighted}}=0.9(2)+0.1(2)=1.8+0.2=2.0\text{ hours}. $$

The weighted comparison prefers curve A, with a mean absolute error of 1.7 hours rather than 2 hours under the assumed deployment mix. This does not make its 8-hour severe-case error unimportant; it shows that the weighted average gives rare severe cases less influence. If those cases have exceptional consequences, a separate severe-case requirement or an asymmetric loss may be needed rather than relying on population frequency alone.

A Practical Selection Process

A defensible comparison connects a clearly defined prediction task to a prespecified loss, then applies that same rule to every candidate curve. The following sequence makes the reasoning explicit.

1
Describe the prediction task.
State what outcome is predicted, the units, who or what receives the prediction, and when it will be used.
2
Describe costly mistakes.
Decide whether large errors, underpredictions, overpredictions, particular groups, or particular ranges have special consequences.
3
Specify the loss before ranking curves.
Choose an interpretable loss and any justified cost rates or group weights. State its units and what a lower value means.
4
Compare on common evaluation cases.
Use predictions made without fitting to those cases, calculate the same loss for each candidate, and report the resulting values in context.
5
Explain the scope of the choice.
Report which curve has lower loss under the stated setup and note important errors or population features the average may hide.

The loss can be selected using subject knowledge, operational priorities, or explicit costs. For example, MAE may be suitable when a unit of error has roughly proportional consequences and extreme errors should not dominate. Squared error may be appropriate when large errors are disproportionately damaging. An asymmetric loss is useful when error direction changes the consequence. Weighted loss can represent a known target mixture of cases. These are choices to justify, not universal rules.

Common Mistakes and Limits

  • Choosing the loss because it makes a preferred curve win. This reverses the logic. Define the prediction consequences and loss first; then compare the candidate curves.
  • Calling the smallest score “the best curve” without qualification. Say which loss, validation cases, and target population support the choice. A curve can rank differently under another reasonable loss.
  • Ignoring units. MAE and RMSE use the outcome's units, while MSE uses squared units. Values from different loss scales should not be treated as directly comparable.
  • Letting an average hide a critical error pattern. A low overall loss can coexist with poor predictions for a rare but important group. Report relevant group performance or encode the cost explicitly.
  • Treating a lower validation loss as proof of a true relationship. It is evidence about predictive performance under the evaluation setup, not proof that a curve is scientifically correct or will always predict better.

For example, it would be incorrect to conclude that curve A is simply superior because its MAE is smaller, while ignoring that the task assigns much higher cost to underprediction. The correction is to evaluate the curves with the loss that represents the stated task and to qualify the conclusion accordingly.

Key takeaway: A curve-selection score has meaning only in relation to its loss function and target use. State what errors cost, calculate the same loss on comparable cases for every candidate, and report the choice as conditional on those decisions.

Check Your Understanding

Answer each question by connecting the calculation to the prediction task.

  1. Two curves have MAEs of 2 minutes and 2.5 minutes, but the first has one very large error. What additional summary could help assess the influence of that error, and why?
  2. For errors \(e=y-\hat{y}\), which sign represents underprediction? Write an asymmetric loss that charges 3 cost points per unit of underprediction and 1 per unit of overprediction.
  3. A balanced validation set contains equal numbers of common and rare cases, but deployment is expected to be 95% common and 5% rare. What information is needed to calculate a deployment-weighted mean loss?
  4. Why do MSE and RMSE rank a fixed set of candidate curves in the same order?
  5. A curve has the lowest weighted MAE, but it performs poorly for a rare, high-consequence group. What should be reported or reconsidered before selecting it?