CAB212 · Unit 2: Regression
Regression metrics: MAE, MSE, RMSE and R-squared
8 practice questions
Key points
- MAE robust; MSE punishes large errors
- RMSE in target units
- R2 = 1 - SS_res/SS_tot
- R2 can be negative
For true values y and predictions p over n samples:
- MAE = mean(|y - p|): average absolute error, same units as y, robust to outliers.
- MSE = mean((y - p)^2): penalizes large errors heavily.
- RMSE = sqrt(MSE): same units as y.
- R-squared = 1 - SS_res / SS_tot, where SS_res = sum((y - p)^2) and SS_tot = sum((y - y_mean)^2). It is the fraction of variance explained.
Worked example: y=[2,4,6,8], p=[3,4,5,10]. Errors 1,0,-1,2. MAE = 1.0, MSE = 1.5, RMSE = 1.2247. y_mean=5, SS_tot=20, SS_res=6, so R-squared = 1 - 6/20 = 0.7.
Exam pitfall: R-squared can be negative on test data when the model is worse than predicting the mean.
Try two questions
Which metric penalizes a single large error most heavily?
- Mean absolute deviation
- MAE
- Median absolute error
- MSE
Show the answer
D. Squaring magnifies large errors.
For the same data the R-squared is:
- 1.5
- 0.7
- 0.85
- 0.3
Show the answer
B. SS_res = 6, SS_tot = 20, so 1 - 6/20 = 0.7.