Machine Learning · Chapter 28 of 40
Regression Metrics
For regression: MAE (mean absolute error), MSE (mean squared error), RMSE (√MSE), R² (coefficient of determination).
MAE is robust to outliers; MSE/RMSE penalise big errors more.
Example 1 (python)
from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score
import math
print(mean_absolute_error(y_test, y_pred))
print(math.sqrt(mean_squared_error(y_test, y_pred)))
print(r2_score(y_test, y_pred))Output
3.2
4.5
0.83Three common metrics.
Example 2 (python)
# R^2 = 1 - SS_res/SS_tot. 1.0 = perfect, 0 = as good as mean.R² intuition.
Key points
- MAE: average absolute error.
- RMSE: penalises big errors more.
- R²: fraction of variance explained.
- Choose based on error cost.
💡 Note: Report metrics in the target's original units (rupees, kg) — much easier for stakeholders to interpret.
