3.5 Coefficient of Determination R²
[video] /api/lesson-media/videos/9b417aa2-5e9f-4ae3-a9db-2a3b7f03f372-1794614952573-cc6500f2c47c17c5.mp4
[markdown] content available only on the platform
[markdown] content available only on the platform
Flashcards · 3.5 Coefficient of Determination R²
R-squared (coefficient of determination) — A score showing how much better a model is than always predicting the mean: 1 - model error / baseline error.
r2_score(y_true, y_pred) -> 0.95
Mean baseline — The laziest regression model, which always predicts the average of the target.
Always predict 4 billion VND for every house.
R-squared = 1 — The model predicts every point exactly, so its error is zero.
Numerator = 0 -> R-squared = 1.
R-squared = 0 — The model is no better than always predicting the mean.
Numerator equals denominator.
Negative R-squared — The model performs worse than simply predicting the mean every time.
Reversed predictions give R-squared = -3.
Explained variation — The share of the target's natural variation that the model accounts for.
R-squared 0.7 -> explains about 70% of price variation.
Normalised metric — A unitless score that can be compared across problems, unlike MAE or MSE.
R-squared is unitless; MAE is in billion VND.
r2_score() — The scikit-learn function that computes R-squared from true and predicted values.
r2_score(actual, predicted)
