R² Score Calculator
Calculate the R-squared coefficient of determination for a regression model.
About R² Score Calculator
R-squared (the coefficient of determination) measures the proportion of variance in the actual values that is explained by the model's predictions: R² = 1 − SS_res/SS_tot, where SS_res is the residual (unexplained) sum of squared errors and SS_tot is the total sum of squared deviations from the mean. R² = 1 means the model perfectly explains all variance, R² = 0 means the model is no better than always predicting the mean, and R² can go negative when the model performs worse than that naive baseline.
Formula
R^2 = 1 - SS_res / SS_tot
- SS_{res}
- Residual sum of squares: sum((y_i - y_hat_i)^2)
- SS_{tot}
- Total sum of squares: sum((y_i - y_mean)^2)
Worked example
With the default values below, R² Score Calculator returns R² (Coefficient of Determination) of 0.9486. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Actual Values
- 3, -0.5, 2, 7
- Predicted Values
- 2.5, 0.0, 2, 8
Results
- R² (Coefficient of Determination)
- 0.9486
- Residual Sum of Squares
- 1.5000
- Total Sum of Squares
- 29.1875
Step by step
- 1Residual sum of squares: SS_res = Σ(y_i − ŷ_i)²= 1.5000
- 2Total sum of squares: SS_tot = Σ(y_i − ȳ)²= 29.1875
- 3R²: 1 − SS_res / SS_tot= 0.9486
Assumptions and limits
- The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 4 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
Can R² be negative?
Yes — a negative R² means the model's predictions are worse than simply predicting the mean of the actual values every time, which can happen with a poorly fit or overfit model evaluated on new data.
Does a high R² always mean a good model?
Not necessarily — R² can be inflated by adding more predictors even if they're not meaningful (which is why Adjusted R² exists), and a high R² doesn't guarantee the model generalizes well to new, unseen data.
How is R² related to correlation?
For simple linear regression with one predictor, R² equals the square of the Pearson correlation coefficient between actual and predicted values, though this equivalence doesn't hold in general for arbitrary prediction models.
