Error Metrics in Predictive Models When evaluating predictive models, itβs essential to quantify how far off the predictions are from actual values. Common metrics include MSE , RMSE , MAE , and MAPE .
1. Mean Squared Error (MSE)
MSE measures the average of the squared differences between predicted and actual values.
MSE = 1 n β i = 1 n ( y i β y ^ i ) 2 \text{MSE} = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2 MSE = n 1 β i = 1 β n β ( y i β β y ^ β i β ) 2
y i y_i y i β = actual value
y ^ i \hat{y}_i y ^ β i β = predicted value
n n n = number of observations
Key Characteristics:
Penalises larger errors more than smaller ones (due to squaring).
Useful when large deviations are particularly undesirable.
Example:
Actual (y i y_i y i β ) Predicted (y ^ i \hat{y}_i y ^ β i β ) 10 12 15 14 20 17
MSE = ( 10 β 12 ) 2 + ( 15 β 14 ) 2 + ( 20 β 17 ) 2 3 = 4 + 1 + 9 3 = 4.67 \text{MSE} = \frac{(10-12)^2 + (15-14)^2 + (20-17)^2}{3} = \frac{4 + 1 + 9}{3} = 4.67 MSE = 3 ( 10 β 12 ) 2 + ( 15 β 14 ) 2 + ( 20 β 17 ) 2 β = 3 4 + 1 + 9 β = 4.67
2. Root Mean Squared Error (RMSE)
RMSE is simply the square root of MSE, bringing the error back to the original unit of measurement.
RMSE = MSE \text{RMSE} = \sqrt{\text{MSE}} RMSE = MSE β
Key Characteristics:
Easier to interpret than MSE because itβs in the same units as the original data.
Still penalises large deviations strongly.
Example:
Using the MSE above:
RMSE = 4.67 β 2.16 \text{RMSE} = \sqrt{4.67} \approx 2.16 RMSE = 4.67 β β 2.16
3. Mean Absolute Error (MAE)
MAE measures the average of the absolute differences between predicted and actual values.
MAE = 1 n β i = 1 n β£ y i β y ^ i β£ \text{MAE} = \frac{1}{n} \sum_{i=1}^{n} \left|y_i - \hat{y}_i\right| MAE = n 1 β i = 1 β n β β£ y i β β y ^ β i β β£
Key Characteristics:
Treats all errors equally (no squaring).
More robust to outliers compared to MSE/RMSE.
Example:
MAE = β£ 10 β 12 β£ + β£ 15 β 14 β£ + β£ 20 β 17 β£ 3 = 2 + 1 + 3 3 = 2.0 \text{MAE} = \frac{|10-12| + |15-14| + |20-17|}{3} = \frac{2 + 1 + 3}{3} = 2.0 MAE = 3 β£10 β 12β£ + β£15 β 14β£ + β£20 β 17β£ β = 3 2 + 1 + 3 β = 2.0
4. Mean Absolute Percentage Error (MAPE)
MAPE expresses the error as a percentage of the actual value.
MAPE = 100 % n β i = 1 n β£ y i β y ^ i y i β£ \text{MAPE} = \frac{100\%}{n} \sum_{i=1}^{n} \left| \frac{y_i - \hat{y}_i}{y_i} \right| MAPE = n 100% β i = 1 β n β β y i β y i β β y ^ β i β β β
Key Characteristics:
Provides an intuitive βpercentage errorβ.
Not suitable when actual values (y i y_i y i β ) can be zero (division by zero problem).
Example:
MAPE = 100 3 ( β£ 10 β 12 10 β£ + β£ 15 β 14 15 β£ + β£ 20 β 17 20 β£ ) \text{MAPE} = \frac{100}{3} \left(
\left|\frac{10-12}{10}\right| +
\left|\frac{15-14}{15}\right| +
\left|\frac{20-17}{20}\right|
\right) MAPE = 3 100 β ( β 10 10 β 12 β β + β 15 15 β 14 β β + β 20 20 β 17 β β )
= 100 3 ( 0.20 + 0.0667 + 0.15 ) β 13.9 % = \frac{100}{3} (0.20 + 0.0667 + 0.15) \approx 13.9\% = 3 100 β ( 0.20 + 0.0667 + 0.15 ) β 13.9%
Summary Table
Metric Formula Penalises Outliers? Units MSE 1 n β ( y β y ^ ) 2 \frac{1}{n}\sum (y-\hat{y})^2 n 1 β β ( y β y ^ β ) 2 Strongly Squared units RMSE MSE \sqrt{\text{MSE}} MSE β Strongly Original units MAE 1 n β β£ y β y ^ β£ \frac{1}{n}\sum \vert y-\hat{y}\vert n 1 β β β£ y β y ^ β β£ Mildly Original units MAPE 100 n β β£ y β y ^ y β£ \frac{100}{n}\sum \left\vert\frac{y-\hat{y}}{y}\right\vert n 100 β β β y y β y ^ β β β Mildly Percentage