R-squared › The R-squared Formula
Michael BrenndoerferApril 4, 20251 min read
Machine Learning from ScratchAll chapters Part 3 of 9Foundations
R-squared › The R-squared FormulaOne section · Sections in this chapter3 / 12 ↓
Sections in this chapter12
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
R-squared is defined as:
Where:
- : Residual sum of squares (unexplained variance)
- : Total sum of squares (total variance)
- : Actual value
- : Predicted value from the model
- : Mean of the actual values
Mathematical Intuition
The formula can be understood through variance decomposition. The total variance in the dependent variable can be split into explained variance (how much the model explains) and unexplained variance (how much remains). R-squared represents the proportion of total variance that is explained by the model. For simple linear regression, R-squared equals the square of the correlation coefficient between the predictor and response variables ().