-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Fix error in euclidean_distances when X is float64 and X_norm_squared is float32
#27624
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you, @jeromedockes.
Can you add a |Fix| changelog entry?
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, non binding.
|
Thanks for the fix! |
…red` is float32 (scikit-learn#27624) Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
…red` is float32 (scikit-learn#27624) Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Reference Issues/PRs
Fixes #27621
What does this implement/fix? Explain your changes.
euclidean_distancesdiscards precomputed squared norms if they are in float32 to avoid numerical precision issues.But in the current implementation there is a code path where the used squared distances end up being
None, when the X and Y are float64 but the squared distances are float32.This PR implements the following logic
X_norm_squaredis provided in float64: use it_euclidean_distances_upcast(as is done ATM when X is float32)and the same for Y
my impression is that this was the original intention but maybe @jeremiedbb can confirm
Any other comments?