Act 6 · Regression bridge · 8 minutes

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:

  1. Total variation (SStot): error from always predicting the mean.
  2. Residual error (SSres): error from using our model.
\[R^2=1-\frac{SS_{res}}{SS_{tot}}=1-\frac{\sum_i(y_i-\hat y_i)^2}{\sum_i(y_i-\bar y)^2}\]
1Perfect fit
0Same as mean
<0Worse than mean
R² is relative. It compares the model with a baseline; it is not an error measured in the target’s units.

Hands-on: improve the model

Move the slider from the mean-only baseline toward a useful fitted line. Red dashed lines are residuals.

65%
feature xy
—R²
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

QuestionClassificationRegression
OutputClass / probabilityContinuous number
What counts as error?Different decision outcomesDistance from actual value
Core tools todayConfusion matrix, precision, recall, F1, ROC-AUCR² 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.

← PR-AUCNext: Teaching guide →