AI Glossary / Statistics and probability / Intermediate

R-squared

Definition

R-squared, or the coefficient of determination, compares a regression model's squared prediction errors with the squared deviations of the observed outcomes from their mean. In the common centered definition, R-squared = 1 - SSE/SST, where SSE is the sum of squared errors and SST is the total sum of squares around the outcome mean. It summarizes relative fit on a specified dataset. It does not establish causality, guarantee useful prediction, or measure accuracy as a percentage of exactly correct answers.

What it means

An R-squared of 0.80 means the squared-error total is 20% of the mean-based reference total under this definition. In ordinary in-sample least-squares regression with an intercept, this is often described as explaining 80% of the observed variation.

That wording is statistical, not causal. Outside the usual fitted-model setting, it is safer to describe the explicit error comparison. On held-out data, R-squared can be negative when predictions are worse than using that evaluation dataset's mean. The mean used in this scoring denominator is a reference for evaluation; it may not be a forecast that was available before the outcomes occurred.

How it works

Choose the evaluation observations and retain their actual outcomes and corresponding predictions. Calculate the mean of the actual outcomes. Sum squared deviations from that mean to obtain SST, and sum squared prediction errors to obtain SSE. Provided SST is positive, calculate 1 - SSE/SST.

State whether the score describes training fit or held-out performance. Use the same observations, outcome scale, and weighting convention when comparing models. A score for a transformed outcome answers a different question from a score on the original scale. Multi-output models also require an explicit aggregation rule.

If outcomes are constant, the centered denominator is zero and the ordinary formula is not well-defined. Software may apply special conventions, so inspect the implementation rather than reporting a convenient replacement without context. Adjusted R-squared adds a model-size penalty in the classical regression setting, but it is still not a substitute for appropriate out-of-sample evaluation or assessment of the actual business loss.

Three practical examples

  • An AI regression team compares models on the same held-out dataset using R-squared alongside errors in the outcome's original units.
  • A forecasting analyst distinguishes a strong historical fit from performance on later periods.
  • A reviewer checks whether reported scores use the same target transformation, sample, and weighting before treating them as comparable.

Think of it this way

Think of a model competing against a simple reference that predicts the evaluation sample's average outcome for everyone. R-squared records the proportional reduction in squared error relative to that reference. A score below zero means the model lost that comparison. It does not mean a negative percentage of reality was explained, and it does not show whether the reference itself was operationally available or adequate.

Worked example

In an original example, actual outcomes are 2, 4, 6, and 8 units, with mean 5. Their total squared deviation is (2 - 5)^2 + (4 - 5)^2 + (6 - 5)^2 + (8 - 5)^2 = 9 + 1 + 1 + 9 = 20.

Predictions of 3, 3, 5, and 9 have errors -1, 1, 1, and -1. Their squared-error total is 4, so R-squared = 1 - 4/20 = 0.80. The root mean squared error is square root(4/4) = 1 unit. Thus the score gives a relative comparison while RMSE supplies an absolute error scale.

If another model predicts 10 for every observation, its squared errors are 64, 36, 16, and 4, totaling 120. Its R-squared is 1 - 120/20 = -5. A perfect prediction would have SSE = 0 and score 1. These values demonstrate that the common score has an upper bound of one but can be negative without limit as predictions worsen. The forecasts are stipulated for arithmetic; no model training or generalization claim is implied.

Illustrative case study

Fictional case study: Oak Forecasting presents a high training R-squared for an AI workload model. A reviewer asks for the score on a later period, the mean absolute error, and performance during peak demand.

The team adds those evaluations and explains the reference used by each metric. It treats the original fit statistic as one part of the evidence rather than the final deployment decision. This fictional case illustrates evaluation scope, not a real model result or a claim that every high training score reflects overfitting.

Common misconceptions and mistakes

R-squared is not the percentage of predictions that are correct. Regression errors are usually continuous, and the score compares squared totals. A high value also does not show that a predictor causes the outcome or that the model is well calibrated in every subgroup.

Adding predictors to an ordinary unpenalized least-squares model on the same training data cannot reduce its training R-squared, even if the added variables have little practical value. The square of the correlation between outcomes and arbitrary predictions is not generally the same as R-squared. Constant bias can affect error-based R-squared while leaving correlation unchanged. Pseudo-R-squared measures for other model families need their own definitions.

Business use

R-squared can provide a compact relative-fit summary when the evaluation setting is clear. It is most useful alongside metrics that reflect actual costs and the scale of errors.

Report the dataset, time window, target definition, and whether observations were held out. Examine residual patterns and subgroup errors. Avoid comparing scores across populations with very different outcome variability as if the denominator were fixed. A low R-squared can coexist with useful predictions for a noisy target, while a high score can coexist with errors too costly for deployment. The business question determines the required evidence.

People also ask

Can R-squared be negative?

Yes, especially for held-out predictions or other predictions worse than the mean reference.

Is R-squared always the squared correlation?

No. That identity requires particular regression conditions and does not hold for arbitrary predictions.

Does R-squared of one prove the model will predict future data perfectly?

No. It describes perfect fit only on the evaluated observations.

Check your understanding

If SST = 20 and SSE = 30, what is R-squared?

Answer: 1 - 30/20 = -0.50. The model has greater squared error than the mean-based reference on that dataset.

Related terms

  • Coefficient of determination
  • Correlation
  • Overfitting
  • residual sum of squares
  • total sum of squares
  • adjusted R-squared
  • RMSE
  • held-out evaluation
  • explained variance

Learn next

Calculate SSE and SST by hand, then compare R-squared with RMSE and MAE. Study why training fit differs from generalization and why correlation does not measure every form of prediction error.

  • Correlation

More in Statistics and probability

  • Quantitative data - Quantitative data represent measured amounts or counts expressed numerically.
  • Questionnaire error - Questionnaire error is the part of survey measurement error attributable to a questionnaire's wording, structure, or form.
  • R chart - An R chart is a statistical process control chart that tracks the range within successive subgroups of measurements.
  • Raleigh plot - A Raleigh plot, in the circular-data sense intended here, displays observations as positions around a circle and often adds their mean direction and mean...
  • Ramsey RESET test - The Ramsey RESET test is a regression diagnostic that looks for neglected nonlinear structure by adding functions of the original model's fitted values or...
  • Random error - Random error is the component of an estimate's or measurement's deviation that varies unpredictably across repetitions of a specified process.

Sources

Scikit-learn's official R-squared documentation explains negative values, the mean reference, constant-target handling, and differences from explained variance: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.r2_score.html

The outcome vectors, error calculations, and fictional case are original and independently checked. This entry uses centered R-squared, not a pseudo-R-squared measure.

Previous: R-precision Next: Rademacher complexity

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer