Computing Library › Machine Learning
Machine Learning

Regression Metrics

Regression metrics such as MSE, MAE, and R-squared quantify how far continuous predictions fall from the truth.

Measuring continuous error

For regression, error is the numeric gap between predictions and targets. Different metrics summarize these residuals differently, and each answers a different question, so reporting more than one gives a fuller picture.

The common metrics

Kronos motion — lego machine

MSE versus MAE

Because MSE squares residuals, a few large errors dominate it, so minimizing MSE fits the conditional mean and is sensitive to outliers. MAE weights all errors linearly, fits the conditional median, and resists outliers. Choose based on whether large errors are disproportionately costly (MSE) or should be treated proportionally (MAE).

python
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
rmse = mean_squared_error(y_true, y_pred, squared=False)
mae  = mean_absolute_error(y_true, y_pred)
r2   = r2_score(y_true, y_pred)

Reading R-squared honestly

R-squared compares your model to a baseline that always predicts the mean. It never decreases when you add features, so adjusted R-squared penalizes extra features to keep the comparison fair. A high R-squared on training data means little; report metrics on a held-out test set. Match the reporting metric to the loss the model optimized where possible.