R² Calculator

Coefficient of determination (R²) for regression predictions.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

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

1
Step 1
Enter the actual values.
2
Step 2
Enter the predicted values in the same order.
3
Step 3
Press Calculate.

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?
Compute 1 minus the residual sum of squares divided by the total sum of squares. The tool does it from your two lists.
Can R-squared be negative?
Yes, if the model fits worse than simply predicting the mean.
What is a good R-squared?
It depends on the field. 0.7 may be excellent for noisy data and poor for physics.
How is this different from the regression tool?
That tool fits a line to two CSV columns; this one scores predictions from any model.

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 YouTube
  • Machine 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.