TATECHATLAS
◎ English
Math & models / Tip

Choosing MAE or RMSE for Forecasting: When to Embrace Linear or Quadratic Loss

Decide between MAE and RMSE by aligning the loss with the target functional - mean versus median - and the business tolerance for large errors. RMSE magnifies outliers while MAE keeps them linear, affecting risk‑sensitive decisions.

On this page

In supervised forecasting, the loss you pick is not a cosmetic choice; it encodes the statistical property you wish to estimate and the cost structure of prediction errors. The scikit‑learn documentation explains that a strictly consistent scoring function must match the functional you are predicting. If you are predicting the mean of a conditional distribution, the mean‑squared error (MSE) is the natural loss: it is strictly consistent for the mean and its minimiser is the expected value. If you are predicting the median, the mean‑absolute error (MAE) is strictly consistent; its minimiser is the conditional median. This distinction is critical because the mean is more sensitive to extreme values than the median. Consequently, a model trained to minimise MSE will try to reduce large deviations more aggressively than one trained to minimise MAE. The choice also reflects the business penalty for large errors. RMSE, the square root of MSE, amplifies outliers: an error that is twice as large contributes four times as much to the loss. MAE treats all errors linearly; a 10‑unit error is twice as bad as a 5‑unit error, regardless of magnitude. In risk‑averse contexts - such as power grid load forecasting where a few under‑predicted peaks can trigger costly remedial actions - RMSE is often preferred because it penalises those extreme under‑predictions heavily. In contrast, if the operational cost is roughly proportional to absolute deviation - say, a logistics company that pays a flat fee per unit of forecast error - MAE is more interpretable and robust to occasional sensor glitches. When training, using the same loss for both optimisation and evaluation is advisable. scikit‑learn’s mean_squared_error and mean_absolute_error functions both return non‑negative floats, with 0.0 as the best possible value. They also accept sample_weight and multioutput parameters, allowing you to weight particular time periods or output dimensions differently. A concrete illustration: a utility company forecasts the 99th‑percentile of daily peak load. The target functional is a quantile, so the pinball loss is the correct training loss. After training, the company evaluates the same predictions with MAE and RMSE. Suppose the MAE is 1.2 MW and the RMSE is 2.5 MW. The RMSE being more than twice the MAE indicates that a few days with very low predictions (perhaps due to sensor outages) inflate the squared error. If the service level agreement penalises large under‑predictions heavily, RMSE better reflects the SLA cost; if the SLA cares about average deviation, MAE is preferable. In practice, consider the following decision checklist: - Target functional: mean → MSE/RMSE; median → MAE; quantile → pinball. - Error distribution: heavy‑tailed → MAE is more robust; light‑tailed → RMSE is fine. - Business cost: linear penalty → MAE; quadratic or exponential penalty → RMSE. - Model training: use a differentiable loss (RMSE) if you rely on gradient‑based optimisers; MAE can be optimised with sub‑gradient methods. - Interpretability: MAE is in the same units as the target and directly interpretable as average absolute deviation. By aligning the loss with the statistical target and the cost structure, you ensure that the metric you optimise and report truly reflects the decision problem at hand.

Choosing the Right Loss for the Target Functional

The scikit‑learn guide states that a strictly consistent scoring function must match the functional you are predicting. If you predict the mean of a conditional distribution, mean‑squared error (MSE) is strictly consistent; if you predict the median, mean‑absolute error (MAE) is strictly consistent. This alignment ensures that the loss you minimise during training is the same loss you use for evaluation, preventing a mismatch between optimisation objective and reporting metric.

Quantifying the Impact of Large Errors

RMSE is the square root of MSE and therefore squares each error before averaging. An error twice as large contributes four times as much to the loss. MAE, by contrast, sums absolute errors linearly, so a 10‑unit error is only twice as costly as a 5‑unit error. In risk‑sensitive contexts - such as power grid peak load forecasting - RMSE will highlight a few extreme under‑predictions that could trigger expensive remedial actions, while MAE will give a more balanced view of average deviation.

Practical Example: Forecasting Daily Peak Load

A utility company forecasts the 99th‑percentile of daily peak load. The target functional is a quantile, so the pinball loss is used for training. After training, the same predictions are evaluated with MAE and RMSE. Suppose MAE = 1.2 MW and RMSE = 2.5 MW. The RMSE being more than twice the MAE indicates that a few days with very low predictions inflate the squared error. If the SLA penalises large under‑predictions heavily, RMSE is the better metric; if the SLA cares about average deviation, MAE is preferable.

import numpy as np
from sklearn.metrics import mean_absolute_error, mean_squared_error

# Example predictions and true values
y_true = np.array([10, 12, 9, 15, 8])
y_pred = np.array([9, 13, 8, 14, 7])

mae = mean_absolute_error(y_true, y_pred)
rmse = mean_squared_error(y_true, y_pred, squared=False)
print(f"MAE: {mae:.2f} MW, RMSE: {rmse:.2f} MW")

When to Prefer MAE over RMSE and Vice Versa

MAE is robust to outliers and easier to interpret because it is in the same units as the target. RMSE emphasises large errors and is differentiable, which is advantageous for gradient‑based optimisers. Choose MAE when you want a stable estimate of average absolute deviation and when occasional extreme errors are not catastrophic. Choose RMSE when the cost of large errors grows faster than linearly, or when you need a smooth loss for optimisation.

Applicability

  • Does the loss function match the statistical functional you intend to estimate?
  • Are you comfortable with the quadratic penalty of RMSE for extreme errors?
  • Do you need a differentiable loss for your optimiser?
  • Is interpretability in the target units a priority?
  • Does the business SLA penalise large deviations more heavily than small ones?

The comparison assumes independent, identically distributed errors and ignores heteroscedasticity or autocorrelation. In time‑series forecasting, additional diagnostics such as residual plots or Ljung-Box tests should accompany metric selection.

Sources

  1. scikit-learn: model evaluation ↗
  2. scikit-learn: mean_absolute_error ↗
Back to top ↑