Metrics - R-Squared and Adjusted R-Squared
What R² measures
R² (coefficient of determination) measures how much variance in the target is explained by the model.
- R² = 1 → perfect predictions
- R² = 0 → no better than predicting the mean
- R² < 0 → worse than predicting the mean
The intuition
R² compares:
- your model error
- vs baseline error (predicting the mean)
Why R² can be misleading
- adding more features can increase R² even if features are useless
- doesn’t tell you the error magnitude (RMSE/MAE do)
Adjusted R²
Adjusted R² penalizes adding features that don’t help much.
It’s useful for comparing models with different numbers of predictors.
Scikit-learn example
R² score
from sklearn.metrics import r2_score
r2 = r2_score(y_true, y_pred)
print("R2:", r2)R² score
from sklearn.metrics import r2_score
r2 = r2_score(y_true, y_pred)
print("R2:", r2)What metrics to use in practice
Use a combination:
- MAE (mean absolute error): easy to interpret
- RMSE: punishes big errors
- R²: variance explanation (but not sufficient alone)
Mini-checkpoint
If your model has R² = 0.92 but RMSE is huge, what does that imply?
- It might explain variance well but still be too inaccurate for real use.
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
