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 cast to Python scalar in Matthews Correlation metric #3001

Merged
merged 1 commit into from
Oct 4, 2021

Conversation

mariosasko
Copy link
Collaborator

This PR is motivated by issue #2964.

The Matthews Correlation metric relies on sklearn's matthews_corrcoef function to compute the result. This function returns either float or np.float64 (see the source). Obviously, calling .item() on the float value will fail, so I'm fixing this with the built-in float() function, which covers both cases. Surprisingly, on my machine, casting np.float64 to a Python scalar with float() is even faster than with the .item() method.

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

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

Cool thanks :)

@lhoestq lhoestq merged commit 743c73d into huggingface:master Oct 4, 2021
@mariosasko mariosasko deleted the fix-matthews-corr-type-cast branch October 4, 2021 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants