-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FEA Introduce PairwiseDistances
#23958
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
Closed
jjerphan
wants to merge
51
commits into
scikit-learn:main
from
jjerphan:feat/pairwise_distances-pdr-backend
Closed
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
0383b6d
Introduce PairwiseDistances
jjerphan e1bf6c9
Merge branch 'main' into maint/pairwise_distances-pdr-backend
jjerphan 5889e6f
WIP
jjerphan 82347ff
Merge branch 'main' into maint/pairwise_distances-pdr-backend
jjerphan 9101daf
fixup! Introduce PairwiseDistances
jjerphan dff1aa2
Post-merge fix
jjerphan 78f066c
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan 44d9453
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan 26f53a8
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan 726858b
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan f573a59
fixup! Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan 24fa994
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan 8e17871
Do not offset by X_start and Y_start
jjerphan 1f1a3ce
Do not progated metric_kwargs unneedlessly
jjerphan 800e6b3
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan 045a7b2
Use the proper vectors' indices
jjerphan 2b70db8
Port PairwiseDistances to support float32 datasets
jjerphan f9431cc
Simplify indices
jjerphan 24cfd04
Adapt implementations for a previous 'sqeuclidean' specification
jjerphan 527a43c
TST Downcast distance matrix to float32
jjerphan d26fafb
Adapt instanciation
jjerphan 81b74e1
Use PairwiseDistances as a back-end for haversine_distances
jjerphan 0aa688e
Use PairwiseDistances as a back-end for manhattan_distances
jjerphan 0006764
Use PairwiseDistances as a back-end for euclidean_distances
jjerphan 05b5ae7
Remove duplicated line
jjerphan 709cdf2
Merge branch 'scikit-learn:main' into feat/pairwise_distances-pdr-bac…
jjerphan 53d6c07
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan 5442ddd
TST Remove checks on errors now that minkowski with sparse data is su…
jjerphan 7087ad1
TST PairwiseDistances factory methods
jjerphan 34aad28
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan 33560b2
DOC Remove comment regarding X_is_Y
jjerphan cfc145a
Preserve dtype for PairwiseDistances
jjerphan 54ebaeb
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan 8604ec6
TST Remove TODO now that dtypes are preserved
jjerphan 62a751a
DOC Remove and adapt some comments
jjerphan 259edc1
MAINT Remove _sparse_manhattan
jjerphan 50f032e
Use PairwiseDistance as a back-end for _euclidean_distances
jjerphan 40d0a0b
MAINT Keep classmethods at the top
jjerphan 9017aa7
Safely pack {X,Y}_squared_norms
jjerphan dd136a7
TST Adapt test_euclidean_distances_extreme_values
jjerphan 91b3205
DOC Improve docstrings
jjerphan 0abe560
Simplify manhattan_distances
jjerphan b5003f9
fixup! DOC Improve docstrings
jjerphan f38b010
fixup! TST Adapt test_euclidean_distances_extreme_values
jjerphan f2d8cbe
Apply review comments
jjerphan d0196f1
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan 3673479
Rework poping {X,Y}_norm_squared in DatasetsPair.get_for
jjerphan 0c74856
Rework poping {X,Y}_norm_squared in EuclideanPairwiseDistances
jjerphan 4fccb5f
DOC Add references to #24745
jjerphan e58de02
Merge branch 'main' into feat/pairwise_distances-pdr-backend
jjerphan eabe44d
Merge remote-tracking branch 'upstream/main' into feat/pairwise_dista…
jjerphan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
39 changes: 39 additions & 0 deletions
39
sklearn/metrics/_pairwise_distances_reduction/_pairwise_distances.pxd.tp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{{py: | ||
|
||
implementation_specific_values = [ | ||
# Values are the following ones: | ||
# | ||
# name_suffix, INPUT_DTYPE_t | ||
# | ||
# | ||
('64', 'cnp.float64_t'), | ||
('32', 'cnp.float32_t') | ||
] | ||
|
||
}} | ||
cimport numpy as cnp | ||
|
||
from ...utils._typedefs cimport DTYPE_t | ||
{{for name_suffix, INPUT_DTYPE_t in implementation_specific_values}} | ||
|
||
from ._base cimport BaseDistancesReduction{{name_suffix}} | ||
from ._middle_term_computer cimport MiddleTermComputer{{name_suffix}} | ||
|
||
|
||
cdef class PairwiseDistances{{name_suffix}}(BaseDistancesReduction{{name_suffix}}): | ||
"""float{{name_suffix}} implementation of PairwiseDistances.""" | ||
|
||
cdef: | ||
{{INPUT_DTYPE_t}}[:, ::1] pairwise_distances_matrix | ||
|
||
|
||
cdef class EuclideanPairwiseDistances{{name_suffix}}(PairwiseDistances{{name_suffix}}): | ||
"""EuclideanDistance-specialized float{{name_suffix}} implementation for PairwiseDistances.""" | ||
cdef: | ||
MiddleTermComputer{{name_suffix}} middle_term_computer | ||
const DTYPE_t[::1] X_norm_squared | ||
const DTYPE_t[::1] Y_norm_squared | ||
|
||
bint use_squared_distances | ||
|
||
{{endfor}} |
Oops, something went wrong.
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.
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.
Side-note: it would be nice not to have duplication with identical lines in
.gitignore
, yet I am not sure this is doable.