AI GLOSSARY · AI CONCEPTS
R-squared
Definition
R-squared compares a regression model's squared prediction errors with the errors from always predicting the observed target mean. Higher is better, but the score can be negative.
Also called: R², coefficient of determination.
In plain language
R-squared, or R², is a regression score. It equals 1 minus the model's sum of squared errors divided by the sum of squared deviations from the true target mean. A score of 1 is perfect; 0 matches the mean baseline; negative is worse.
Technical definition
For nonconstant true targets, R² = 1 - residual sum of squares / total sum of squares, where residual sum of squares is sum((true - predicted)^2) and total sum of squares is sum((true - mean(true))^2). Constant targets make the denominator zero, so the formal expression is undefined.
Worked examples in this catalogue
Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.
Skill by Skill Almanac · Illustrative, not executed
data-analysis-eda 56/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- Before computing a regression score, profile the supplied CSV and inspect the target column type, missingness and distribution.
- Why it exercises the concept
- R-squared needs meaningful numeric target values and a nonzero total sum of squares. This preparatory descriptive check helps inspect the target; the skill does not fit a regression model or calculate or validate R-squared.
How it shows up when you use agents
R-squared, written R² and also called the coefficient of determination, evaluates numeric predictions from a regression model. An agent system might use such a model to estimate resolution time, cost or another continuous target.
In plain text, the formula is: R-squared equals 1 minus the sum of squared prediction errors divided by the sum of squared differences between each true value and the mean of the true values. The mean-prediction baseline therefore scores 0, while perfect predictions score 1 when the target is not constant.
Here is an explicitly hypothetical negative example. Let the true values be 1, 2 and 3, so their mean is 2. Predict 3, 2 and 1. The squared prediction errors are 4, 0 and 4, totaling 8. The squared deviations of the true values from their mean are 1, 0 and 1, totaling 2. Therefore R² = 1 - 8/2 = 1 - 4 = -3. The negative score correctly signals that these predictions are worse than always predicting 2.
As a reader action, compare R² on held-out data against a clearly stated baseline, then inspect errors in the target's original units. Report the evaluated population and target alongside the score.
Common confusions
R² is not confined to the interval from 0 to 1. It can be negative when a model performs worse than the mean baseline. It is not classification accuracy, and a high value does not establish that features caused the target.
Do not assume R² is always the square of a correlation. That identity requires particular conditions and is not the general definition of the regression score.
A constant true target needs special care. Every true value then equals its mean, making the formula's denominator zero; formally, the score is undefined rather than an ordinary finite R². scikit-learn documents the underlying outcomes as NaN for perfect predictions and negative infinity for imperfect predictions. Its optional force_finite=True default replaces those results with 1.0 and 0.0, respectively, for practical use in higher-level procedures. Those replacements are implementation behavior, not a change to the formal formula.
Related terms
More in AI concepts
Sources
- Machine Learning Glossary: R-squared, Google for Developers (accessed 2026-11-25)
- r2_score, scikit-learn (accessed 2026-11-25)
Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-25. Wikipedia is never the only source.
Review record
Last verified
Drafted by OpenAI Codex (configured gpt-5.6-sol); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-25. Last verified .
Change log (3)
- : Independent automated source/example and simulated-reader review closed. Cached broad US definition-query estimate; not AI-exclusive or promised traffic. Final runtime gate recorded separately; publication disabled.
- : Private sourced draft; independent factual, reader and runtime gates pending. Cached broad US demand is not AI-exclusive.
- : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.