Repository navigation
Fix error in euclidean_distances when X is float64 and X_norm_squared is float32 - #27624
Merged
Merged
Conversation
jjerphan
approved these changes
Oct 21, 2023
jjerphan
left a comment
Member
There was a problem hiding this comment.
LGTM. Thank you, @jeromedockes.
Can you add a |Fix| changelog entry?
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Member
|
Thanks for the fix! |
glemaitre
pushed a commit
to glemaitre/scikit-learn
that referenced
this pull request
Oct 31, 2023
…red` is float32 (scikit-learn#27624) Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
REDVM
pushed a commit
to REDVM/scikit-learn
that referenced
this pull request
Nov 16, 2023
…red` is float32 (scikit-learn#27624) Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
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.
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?