What is R-squared (R²)?
R-squared (R²) measures how much better a regression model explains the target values compared with a simple baseline that always predicts the mean target value.
It is also called the coefficient of determination.
Formula
R² = 1 - (SS_res / SS_tot)where:
SS_resis the sum of squared residuals from the modelSS_totis the total squared deviation of the actual values from their mean
Intuition
Suppose the baseline predicts the average target for every observation.
R² compares the model's squared error with the error from that mean baseline.
If the model reduces the error substantially, R² becomes larger.
How to interpret R²
R² = 1.0means the model predicts the evaluated data perfectly.
R² = 0means the model performs no better, in squared-error terms, than simply predicting the mean target value.
For example:
R² = 0.80is commonly interpreted as the model accounting for about 80% of the variation in the target relative to the mean baseline.
Can R² be negative?
Yes.
A negative R² means the model performs worse than the mean-prediction baseline on the evaluated data.
This can happen especially on validation or test data when a model generalizes poorly.
Is a higher R² always better?
A higher R² generally indicates a better fit on the same dataset, but it should not be used alone.
A model can have a high R² and still:
- overfit the training data
- make errors that are too large for the business problem
- show systematic patterns in its residuals
- rely on unnecessary features
R² does not show error size
R² is unitless.
It does not directly tell you whether predictions are off by ₹100, ₹10,000, or another practical amount.
That is why it is often used together with metrics such as MAE or RMSE.
Be careful when comparing models
R² is most meaningful when models are evaluated on the same target and the same dataset.
Adding more predictors to an ordinary regression model can also increase training R² even when the new features are not useful, which is one reason adjusted R² is sometimes used.
In short, R² measures how much a regression model improves over predicting the target mean in terms of squared error. Higher values usually indicate a better fit, but R² should be interpreted together with error metrics and validation performance.
Learning Sequence
Machine Learning Curriculum
Explore Related Questions
Deepen your understanding across related Machine Learning topics.