Commit 0a38429
committed
fix(metrics): correct explained_variance residual-variance term
The residual-variance numerator in explained_variance subtracted the raw
residual mean from a sum of squared residuals, mixing units of y with
units of y^2. Explained variance is 1 - Var(y_true - y_pred) / Var(y_true),
so the numerator must be the sum of squared deviations of the residuals
from their mean.
For y_true=[0,0.1,0.2,0.3,0.4], y_pred=[0.1,0.3,0.2,0.5,0.7] the function
returned 0.8; the correct explained variance is 0.48, matching
sklearn.metrics.explained_variance_score. Update the test accordingly.1 parent 7fe5c86 commit 0a38429
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
| |||
474 | 476 | | |
475 | 477 | | |
476 | 478 | | |
477 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
478 | 483 | | |
479 | 484 | | |
480 | 485 | | |
| |||
0 commit comments