lemma-osu / sknnr

scikit-learn compatible estimators for various kNN imputation methods
https://sknnr.readthedocs.io
0 stars 1 forks source link

Fix `r2_score` port test #70

Closed grovduck closed 4 months ago

grovduck commented 4 months ago

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 commented 4 months ago

@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.