R Squared
noun
say it: “AR SKWAIRD” /ˈɑr ˈskwɛrd/
A number, usually from 0 to 1, that says how much of the variation in the real values a model's predictions explain.
What is R squared?
R squared (R²) says how much better a model does than always guessing the average: 1 means perfect guesses, 0
means no better than the average, and below 0 means worse. r2_score() and a regression model's score() give it.
from sklearn.metrics import r2_score
minutes = [30, 25, 40, 35]
print(r2_score(minutes, [29, 26, 38, 35])) # 0.952
print(r2_score(minutes, [32.5] * 4)) # 0.0: always the average
In a sentence
- “Guessing the average every time gives an R squared of exactly 0.”
- “An R squared of 0.95 meant the model explained almost all the ups and downs in delivery times.”
Level: Journeyman · More AI Basics terms at this level
Updated