# pulse2percept.utils.stats¶

Functions

 circ_r2_score(y_true, y_pred) Calculate circular R² (the coefficient of determination) r2_score(y_true, y_pred) Calculate R² (the coefficient of determination)
pulse2percept.utils.stats.circ_r2_score(y_true, y_pred)[source]

Calculate circular R² (the coefficient of determination)

The best possible score is 1.0, lower values are worse.

New in version 0.7.

Parameters: y_true (array-like) – Ground truth (correct) target values. y_pred (array-like) – Estimated target values. z (float) – The R² score

Notes

• If the ground-truth data has zero variance, R² will be zero.
• This is not a symmetric function
pulse2percept.utils.stats.r2_score(y_true, y_pred)[source]

Calculate R² (the coefficient of determination)

The r2_score function computes the coefficient of determination, usually denoted as R².

The best possible score is 1.0, lower values are worse.

It represents the proportion of variance (of y) that has been explained by the independent variables in the model. It provides an indication of goodness of fit and therefore a measure of how well unseen samples are likely to be predicted by the model.

If $$\hat{y}_i$$ is the predicted value of the $$i$$-th sample and $$y_i$$ is the corresponding true value for total $$n$$ samples, the estimated R² is defined as:

$R^2(y, \hat{y}) = 1 - \frac{\sum_{i=1}^{n} (y_i - \hat{y}_i)^2}{\sum_{i=1}^{n} (y_i - \bar{y})^2}$

where $$\bar{y} = \frac{1}{n} \sum_{i=1}^{n} y_i$$ and $$\sum_{i=1}^{n} (y_i - \hat{y}_i)^2 = \sum_{i=1}^{n} \epsilon_i^2$$.

Note that r2_score calculates unadjusted R² without correcting for bias in sample variance of y.

New in version 0.7.

Parameters: y_true (array-like) – Ground truth (correct) target values. y_pred (array-like) – Estimated target values. z (float) – The R² score

Notes

• If the ground-truth data has zero variance, R² will be zero.
• This is not a symmetric function