R² Calculator
Coefficient of determination (R²) for regression predictions.
About this tool
Enter actual and predicted values and get R², the coefficient of determination: the share of the variance in the actual values that your predictions explain. 1 is perfect, 0 is no better than predicting the mean, and it can go negative for poor models.
How to use
How it works
R² = 1 − SS_res / SS_tot, where SS_res is the sum of squared prediction errors and SS_tot is the sum of squared deviations of the actual values from their mean. Unlike the regression tool, this takes predictions from any model, so R² can be negative.
R² = 1 − SS_res / SS_tot
Worked example
Four predictions
- Input
- Actual: 3, 5, 2.5, 7 Predicted: 2.5, 5, 4, 8
- Output
- R² 0.724138; SS_res 3.5; SS_tot 12.6875; n 4
- Walkthrough
- 1 − 3.5 / 12.6875 = 0.7241. The model explains about 72% of the variance in the actual values.
Limitations
- Same-length lists required.
- R² alone does not show whether predictions are biased or the model is appropriate.
- On a test set it can be negative if predictions are worse than the mean.
Questions
How do I calculate R-squared?
Can R-squared be negative?
What is a good R-squared?
How is this different from the regression tool?
Features
- SS_res and SS_tot shown
- Works for any model's predictions
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
Finding mean, median, and mode
Khan Academy
Baseline stats for accuracy and evaluation helpers.
Watch on YouTubeMachine Learning for Everybody
freeCodeCamp.org
Accessible ML survey for AI calculator and metric tools.
Watch on YouTube
- Data Index
Math is Fun
Stats primers when reading ML evaluation outputs.
- Metrics and scoring
scikit-learn
Precision, recall, F1 definitions used by AI metric tools.