Key takeaway
R² compares squared error with a defined reference variation. Keep that denominator and constant-target policy beside the score before comparing reports.
A negative score can be a meaningful result
A buyer receives an evaluation with R² below zero and assumes the report is corrupt because the name contains squared. The first question is which score was calculated. Scikit-learn’s r2_score can be negative: for nonconstant targets, its zero reference is a constant prediction equal to the evaluated target mean. A result below zero can therefore indicate more squared error than that reference.
R² is a normalized comparison, rather than a quantity in the target’s physical units. Preserve the eligible target set, prediction pairing and score definition. A change in target variation can change this ratio even when absolute prediction errors stay unchanged. That distinction matters when two archives contain different operating ranges or a receiving team compares an aggregate with a narrow subgroup.
Calculate two invented target ranges with the same residuals
This hypothetical fixture has three equally weighted scalar cases per set. The narrow set has targets 1, 2, 3 and predictions 0, 1, 2. The wide set has targets 0, 10, 20 and predictions −1, 9, 19. Units are the same invented quantity units. Every prediction is one unit below its target, so both sets have squared-error sum SSE=3 and RMSE=1 unit.
For the centered definition used here, SST is the sum of squared target deviations from that set’s own target mean. The narrow mean is 2 and SST=1+0+1=2. The wide mean is 10 and SST=100+0+100=200. Thus R²=1−SSE/SST gives −0.5 and 0.985 respectively. The author independently recomputed these quantities locally; no model was fitted and no real benchmark is reported.
| Synthetic evaluated set | SSE | Centered SST | RMSE | R² |
|---|---|---|---|---|
| Targets 1, 2, 3 | 3 | 2 | 1 unit | −0.5 |
| Targets 0, 10, 20 | 3 | 200 | 1 unit | 0.985 |
Do not explain the ratio as a change in absolute accuracy
The second R² is higher because the stated denominator is much larger. The same one-unit residuals have not become smaller. An evaluation owner should retain a target-unit error measure and the target range beside the normalized score. It would be misleading to call the wide-set method operationally superior using this table alone, especially because these are different hypothetical case sets.
Likewise, averaging subgroup R² values does not generally reproduce a score recomputed across pooled cases. Group means and between-group variation alter the pooled denominator. Name the actual reduction rather than treating a dashboard’s average as interchangeable with one ratio over all cases. For multiple outputs, the documented r2_score interface offers separate uniform and variance-weighted reductions; the example uses a single output.
Inspect constant targets and alternative definitions
If every reference target is 3, centered SST is zero. Under the documented raw r2_score behavior, perfect predictions yield NaN and imperfect predictions yield negative infinity. Its default force_finite setting replaces those cases with 1.0 and 0.0 respectively. A displayed zero can therefore be an explicit software replacement rather than an ordinary zero-baseline result on varying targets.
Record that setting and keep constant-target groups visible. Do not silently remove them from a report or describe their substituted values as if the original ratio were finite. One evaluated observation also cannot supply the usual R² definition documented by the function; the receiving method needs a declared policy for insufficient cases.
A second definition trap appears in statsmodels’ regression-results rsquared property: it uses centered total sum of squares when a constant is included, and uncentered total sum of squares when it is omitted. That model-results property is not automatically interchangeable with a generic out-of-sample score. Ask for the function, model specification and denominator before reconciling two R² fields.
Return a denominator-backed acceptance note
For the fictional comparison, the accepted conclusion is that equal residuals produced different normalized scores under different target spreads. It does not identify a deployment winner. The evaluation note records the target unit, eligible cases, target mean, SSE, SST, constant-target policy, sample weights, output reduction and implementation version. Predictions and targets stay aligned at case level so the calculation can be challenged.
If a receiving report supplies only R², request those missing inputs and a target-unit loss before using it for acceptance. A score normalized against the observed test mean is an evaluation reference, not evidence that this mean would have been available to a deployed predictor. Keep that distinction with the benchmark’s information boundary and preserve a separate operational baseline where the decision requires one.