Repository navigation
Fix bugs in Scholar.Metrics.Regression - #377
Merged
josevalim merged 1 commit intoNov 23, 2026
Merged
Conversation
josevalim
approved these changes
Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #376.
r2_scorewith:axes. The total sum of squares used the mean of the whole tensor. It now uses the mean over:axes, soaxes: [0]matches scikit-learn'smultioutput="raw_values". Theaxes: [0]doctest expected the old value and is updated.explained_variance_scoreon rank 2 tensors. The numerator was divided by the size of axis 0 whatever:axeswas, which gave wrong scores without:axes. Withaxes: [1]it raised. Both sides are now means over the same axes.mean_poisson_deviancewith zeros iny_true.0 * log(0)gave NaN. That term is now 0, as with scikit-learn'sxlogy.mean_tweedie_devianceandd2_tweedie_scorewithpower1 had the same problem.Checked against scikit-learn on 300 random inputs (2 to 11 samples, 1 to 4 outputs, Poisson counts) in f64. Before,
r2_scorewithaxes: [0]differed on 232,explained_variance_scorewithout:axeson 232, andmean_poisson_devianceon 244. Now all agree to 1e-9.The four new tests fail on main and pass with this change.