How to use the R-Squared Calculator
- 1. Choose a modeFit a line to x and y data, or enter actual and predicted values from any model.
- 2. Paste your dataTwo numbers per line, separated by spaces, commas or tabs; a header row is fine.
- 3. Read the fitSee R², adjusted R², the line, correlation and residuals for each row.
What R² means
R², the coefficient of determination, is 1 − SS_res ÷ SS_tot. SS_res is the sum of squared differences between actual and predicted values; SS_tot is the sum of squared differences between actual values and their mean. An R² of 0.8 means the model explains 80% of the variation in y. It can be negative when predictions are worse than always guessing the mean. Adjusted R² = 1 − (1 − R²)(n − 1) ÷ (n − p − 1) penalises extra predictors, so it only rises when a new feature genuinely helps.
Worked example
The default data are study hours (x) and marks (y) for 8 students: 52, 55, 61, 64, 70, 71, 78 and 80 for 1 to 8 hours. The least-squares line is y = 47.7857 + 4.1310 × x, so each extra hour adds about 4.1 marks. R² is 0.9874, adjusted R² 0.9853 and r = 0.9937. The residual sum of squares is 9.1548 against a total of 725.8750. Switch to actual and predicted with the same numbers and R² becomes −738.2619. That's because the second column would then be the prediction, and 1–8 is nowhere near marks of 52–80.
Checked against NumPy and scikit-learn
Slopes and intercepts match NumPy's polyfit, and R² values match scikit-learn's r2_score on 30 random datasets. A high R² doesn't prove that x causes y, and it can hide a curved pattern, so always look at the residual column.
Frequently asked questions
What's a good R²?
It depends on the field. Physical measurements often give R² above 0.9; behaviour and business data often fit far less tightly. Compare models on the same data rather than against a fixed number.
Can I do multiple regression here?
The fit mode fits one x. For several features, fit the model elsewhere, paste actual and predicted values and set the number of predictors for adjusted R².
Is the R-squared calculator free?
Yes. You can open the R-squared calculator and enter all your numbers without signing up. When you calculate R² for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.