# Prediction error and coefficient of determination of predicted against observed values, version 1.0.2

score-prediction-error\@1.0.2: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.

## What this page can and cannot show

**Level: Checked against a reference; R² against the observed mean; not a squared correlation; can be negative. Reference kind: our own exact-arithmetic script and a hand-worked case; the source's own worked example, Chicco, Warrens and Jurman 2021, Table 1 and UC2 (printed values), version of record.**

Checked by this project, not independently reviewed. Every method on this page has its equations, constants, sources and cases on record, and its cases agree with the stated reference within the stated tolerance. A reader can follow each method's worked example by hand; that shows the stated method gives the stated answer for one set of inputs, and does not test the code. The other cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed them.

[Every version of this method](https://www.drybench.com/methods/m/score-prediction-error) · [Every method](https://www.drybench.com/methods/m) · [What the levels mean](https://www.drybench.com/methods/levels)

## Version 1.0.2

**Level: Checked against a reference; R² against the observed mean; not a squared correlation; can be negative. Reference kind: our own exact-arithmetic script and a hand-worked case; the source's own worked example, Chicco, Warrens and Jurman 2021, Table 1 and UC2 (printed values), version of record.** `score-prediction-error@1.0.2`

Built, not hosted. Generated from a snapshot of the library's records taken on 2026-11-25, as committed on 2026-11-25. A later snapshot replaces this one, so these records and this page can change.

**Verification statement:** MSE, RMSE, MAE and R² as in Chicco, Warrens and Jurman 2021 (Eqs. 1 and 3 to 6), re-read at source 14 November 2026 with matching SHA-256; Table 1 reproduced. Compared with scikit-learn 1.9.1, eighteen values the source prints, and a second implementation in Python by a separate agent of the same model family (63 cases, 22 at the edges). A squared unit carries a UCUM code only for the units the tool lists.

For m pairs of a predicted and an observed value in one unit: the mean squared error, its root, the mean absolute error, and the coefficient of determination R² = 1 − Σ(X − Y)²/Σ(Ȳ − Y)², the squared error over the spread of the observations about their own mean. R² is not a squared correlation, is negative when the predictions do worse than that mean, changes when the two vectors are exchanged, and is withheld when every observation is equal. An error keeps the values' unit, except that it is in K for values in degC and a log ratio for values on a base-10 logarithmic scale.

- **How results are reported:** none: full double precision
- **Uncertainty:** Arithmetic on the caller's pairs; no sampling interval is computed for any score.
- **Reference, as its record states it:** Exact arithmetic (Python fractions; one square root at 60 digits), checked against scikit-learn 1.9.1 and eighteen values the primary source prints
- **Level confirmed by this project's ruling of** 17 November 2026

[What this page can and cannot show](#what-this-page-can-and-cannot-show)

### What was checked

104 cases in 3 files, linked by this exact version.

Run through the tool at build against our own exact-arithmetic script and a hand-worked case; the source's own worked example, Chicco, Warrens and Jurman 2021, Table 1 and UC2 (printed values), version of record: 89 agree within the tolerance the file states, 15 refuse as the case expects, 0 differ, 0 were not run.

- **File 1, 22 cases**
  - **Where the expected values came from:** our own exact-arithmetic script and a hand-worked case
  - **Recorded on:** 2026-11-12
  - **Reference:** Python standard library (fractions, decimal), 3.13.18; licence PSF-2.0
  - **Tolerance as the file states it:** MSE, RMSE, MAE and R² relative 1e-9, with a floor of 1e-12 below 1e-3; a case in another unit states the same rule in its own units; statuses, codes, the withholding rule and units exact

- **File 2, 19 cases**
  - **Where the expected values came from:** the source's own worked example, Chicco, Warrens and Jurman, PeerJ Comput Sci 7:e623 (2021), doi 10.7717/peerj-cs.623, Table 1 (UC1) and the text of UC2: R² for constructed predictions of the points 1 to 100
  - **Recorded on:** 2026-11-12
  - **Reference:** Chicco, Warrens and Jurman 2021, Table 1 and UC2 (printed values), version of record; licence CC-BY-4.0
  - **Tolerance as the file states it:** R² absolute 0.00005 (half a unit in the printed fourth decimal); MSE, RMSE and MAE relative 1e-9 against scikit-learn; statuses, codes and units exact

- **File 3, 63 cases**
  - **Where the expected values came from:** our own exact-arithmetic script and a hand-worked case
  - **Recorded on:** 2026-11-14
  - **Reference:** second implementation by a fresh agent (Python 3.13), 2026-11-14; licence BSD-3-Clause
  - **Tolerance as the file states it:** every number relative 1e-15 (absolute 1e-30 below 1e-15, in each value's unit); counts, statuses, codes, labels and strings exact

Apart from the worked example, the cases and their values are not printed here. This shows agreement with this project's recorded cases. It does not show that a method suits your work, and it is not a qualification.

### What was not checked

How the pairs were chosen and whether they were held out; the source's other error measures (MAPE, SMAPE), which are not computed; its UC2 start case, whose formula zeroes nine points while its printed value is that of ten; observations whose spread is within rounding of their mean; logarithms other than base 10, which are not taken; a squared unit carries a UCUM code only for the units the tool lists; any sampling interval.

### Definition or model

A closed form: the result follows from the inputs by the equations alone.

### Equations

**Equation 1**

```equation
MSE = (1/m)·Σᵢ (X_i − Y_i)²
```

| Symbol | Meaning and unit |
| --- | --- |
| X\_i | the predicted value of pair i (argument predicted), as-given |
| Y\_i | the observed value of pair i (argument observed), as-given |
| m | the number of pairs |
| MSE | mean squared error, returned as meanSquaredError, as-given^2 |

Source: Chicco D, Warrens MJ, Jurman G, The coefficient of determination R-squared is more informative than SMAPE, MAE, MAPE, MSE and RMSE in regression analysis evaluation, PeerJ Comput Sci 7:e623 (2021), equation 4, section Methods, Mathematical background, version of record (PeerJ) as deposited in PMC; Europe PMC's JATS XML, not the publisher's copy; read in full on 2026-11-12 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning bc24c4109d66. Free to read (CC BY 4.0), checked 2026-11-12. No erratum found (searched crossref, europe-pmc, retraction-watch), 2026-11-12.

**Equation 2**

```equation
RMSE = √MSE
```

| Symbol | Meaning and unit |
| --- | --- |
| MSE | mean squared error, as-given^2 |
| RMSE | root mean squared error, returned as rootMeanSquaredError, as-given |

Source: Chicco D, Warrens MJ, Jurman G, The coefficient of determination R-squared is more informative than SMAPE, MAE, MAPE, MSE and RMSE in regression analysis evaluation, PeerJ Comput Sci 7:e623 (2021), equation 5, section Methods, Mathematical background, version of record (PeerJ) as deposited in PMC; Europe PMC's JATS XML, not the publisher's copy; read in full on 2026-11-12 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning bc24c4109d66. Free to read (CC BY 4.0), checked 2026-11-12. No erratum found (searched crossref, europe-pmc, retraction-watch), 2026-11-12.

**Equation 3**

```equation
MAE = (1/m)·Σᵢ |X_i − Y_i|
```

| Symbol | Meaning and unit |
| --- | --- |
| X\_i | the predicted value of pair i (argument predicted), as-given |
| Y\_i | the observed value of pair i (argument observed), as-given |
| m | the number of pairs |
| MAE | mean absolute error, returned as meanAbsoluteError, as-given |

Source: Chicco D, Warrens MJ, Jurman G, The coefficient of determination R-squared is more informative than SMAPE, MAE, MAPE, MSE and RMSE in regression analysis evaluation, PeerJ Comput Sci 7:e623 (2021), equation 6, section Methods, Mathematical background, version of record (PeerJ) as deposited in PMC; Europe PMC's JATS XML, not the publisher's copy; read in full on 2026-11-12 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning bc24c4109d66. Free to read (CC BY 4.0), checked 2026-11-12. No erratum found (searched crossref, europe-pmc, retraction-watch), 2026-11-12.

**Equation 4**

```equation
Ȳ = (1/m)·Σᵢ Y_i
R² = 1 − Σᵢ (X_i − Y_i)² / Σᵢ (Ȳ − Y_i)²
```

| Symbol | Meaning and unit |
| --- | --- |
| X\_i | the predicted value of pair i (argument predicted), as-given |
| Y\_i | the observed value of pair i (argument observed), as-given |
| m | the number of pairs |
| Ȳ | the mean of the observed values, as-given |
| R² | coefficient of determination, returned as rSquared; at most 1, with no lower bound; undefined when every observation is equal |

Source: Chicco D, Warrens MJ, Jurman G, The coefficient of determination R-squared is more informative than SMAPE, MAE, MAPE, MSE and RMSE in regression analysis evaluation, PeerJ Comput Sci 7:e623 (2021), equation 1 and 3, section Methods, Mathematical background, version of record (PeerJ) as deposited in PMC; Europe PMC's JATS XML, not the publisher's copy; read in full on 2026-11-12 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning bc24c4109d66. Free to read (CC BY 4.0), checked 2026-11-12. No erratum found (searched crossref, europe-pmc, retraction-watch), 2026-11-12.

### Constants

Constants: none used.

### Worked example

Worked example: one case of score-prediction-error\@1.0.2, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.

**Inputs**

- observed.values\[0\] = 5
- observed.values\[1\] = 6
- observed.values\[2\] = 7
- observed.values\[3\] = 8
- observed.values\[4\] = 9
- observed.unit = 1
- predicted.values\[0\] = 5.5
- predicted.values\[1\] = 5.5
- predicted.values\[2\] = 7.5
- predicted.values\[3\] = 8
- predicted.values\[4\] = 8
- predicted.unit = 1

**Steps**

1. squaredErrorSum = 1.75, from observed, predicted; by equation 1.
2. mse = 0.35, from squaredErrorSum; by equation 1; gives meanSquaredError.
3. rmse = 0.59160798, from mse; by equation 2; gives rootMeanSquaredError.
4. absoluteErrorSum = 2.5, from observed, predicted; by equation 3.
5. mae = 0.5, from absoluteErrorSum; by equation 3; gives meanAbsoluteError.
6. observedMean = 7, from observed; by equation 4.
7. spread = 10, from observed, observedMean; by equation 4.
8. rSquared = 0.825, from squaredErrorSum, spread; by equation 4; gives rSquared.

The working, as the case writes it:

```equation
errors 0.5, -0.5, 0.5, 0, -1
Σ(X − Y)² = 1.75, so MSE = 1.75/5 = 0.35 and RMSE = 0.59160798
Σ|X − Y| = 2.5, so MAE = 0.5
the observations' mean is 7 and Σ(Ȳ − Y)² = 10, so R² = 1 − 1.75/10 = 0.825 (worked by hand by Drybench on 12 November 2026
not an independent check)
```

**Answer**

- `meanSquaredError` = **0.35**
- `rootMeanSquaredError` = **0.59160798**
- `meanAbsoluteError` = **0.5**
- `rSquared` = **0.825**

Where these values came from: our own exact-arithmetic script and a hand-worked case; stored reference values (fractions; 60-digit decimal square root).

At build the tool returned this answer within the tolerance the file states: MSE, RMSE, MAE and R² relative 1e-9, with a floor of 1e-12 below 1e-3; a case in another unit states the same rule in its own units; statuses, codes, the withholding rule and units exact.

Who worked this case: not recorded.

### What it refuses, and its input ranges

- `RESULT_OUTSIDE_DOUBLE_RANGE`: an error, a deviation from the observed mean, one of their squares, a sum of them, the mean squared or mean absolute error, or the ratio of the two sums of squares is not finite, or is not zero and below the smallest normal double Next: Check the values and their unit; where they are as intended, no change of input makes this computable on these data.
- `LENGTHS_DIFFER` (invalid input): the observed and the predicted vectors have different lengths: the values are scored pair by pair

### Changes

No correction is logged for score-prediction-error\@1.0.2.

## Tools that use it

- [`score_prediction_error`](https://www.drybench.com/methods/tools/score-prediction-error)

## Cite this version

Prediction error and coefficient of determination of predicted against observed values. Drybench; score-prediction-error\@1.0.2; [https://www.drybench.com/methods/m/score-prediction-error/1.0.2](https://www.drybench.com/methods/m/score-prediction-error/1.0.2) (accessed \[date\]).
