R² asks: did the model beat the mean?
Classification counts decision outcomes. Regression predicts continuous values, so we measure distances between actual and predicted values.
Begin with the simplest baseline
If we know nothing about a house except previous prices, a sensible constant prediction is the average price.
R² compares two piles of squared error:
- Total variation (SStot): error from always predicting the mean.
- Residual error (SSres): error from using our model.
Hands-on: improve the model
Move the slider from the mean-only baseline toward a useful fitted line. Red dashed lines are residuals.
| Model error, SSres | — |
|---|---|
| Baseline variation, SStot | — |
As the model’s squared error shrinks relative to the baseline, R² moves toward 1.
Three interpretations learners often miss
R² = 0.72
The model explains 72% of the variation relative to predicting the mean on this data.
Negative R²
Possible on evaluation data. It means the model performs worse than the mean baseline.
High R² ≠ causation
A strong fit does not prove that an input causes the output—or that predictions generalize.
Classification versus regression
| Question | Classification | Regression |
|---|---|---|
| Output | Class / probability | Continuous number |
| What counts as error? | Different decision outcomes | Distance from actual value |
| Core tools today | Confusion matrix, precision, recall, F1, ROC-AUC | R² relative to mean baseline |
Exit check
Can R² be negative?
Yes. It means the model’s squared error is greater than the error from simply predicting the mean.