Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix r2_score port test #70

Merged
merged 2 commits into from
Jul 10, 2024
Merged

Fix r2_score port test #70

merged 2 commits into from
Jul 10, 2024

Conversation

grovduck
Copy link
Member

@grovduck grovduck commented Jul 10, 2024

As part of using the Array API for r2_score, the return value of r2_score is now cast explicitly as a float rather than np.float64 when it is a scalar value.

From this doc:

Note however that scoring functions that return scalar values return Python scalars (typically a float instance) instead of an array scalar value.

In test_port.test_score_independent, we were calling r2_score using the default multioutput="uniform_average" which was returning a single np.float64. We were then mistakenly calling .mean() on this value which had not previously thrown an error because it was operating on a np.float64. With the change in return type, this test now throws an error at scikit-learn>=1.5.

Simply removing .mean() corrects this test.

@grovduck
Copy link
Member Author

@aazuspan, my reasoning in #69 on this error was flawed and I thought it would be a good idea to keep this separate. I've also added a slight change to the CI config to explicitly list the dependency package versions used in the CI tests. There might be a way to get this info from the CI logs already, but I coudn't find it.

@grovduck grovduck self-assigned this Jul 10, 2024
@grovduck grovduck added the bug Something isn't working label Jul 10, 2024
Copy link
Contributor

@aazuspan aazuspan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, thanks for explaining the underlying issue. Makes sense! The pip freeze is a good addition.

LGTM!

@grovduck grovduck merged commit 20d3a65 into main Jul 10, 2024
13 checks passed
@grovduck grovduck deleted the r2-score-fix branch July 10, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants