Repository navigation
MNT Deprecate metrics.pairwise.paired_*_distances and paired_distances public functions - #30537
SuccessMoses wants to merge 6 commits into
Conversation
|
I am just commenting to let you know that we are short in reviewers and in time. Your efforts are very appreciated @SuccessMoses! I am sorry we cannot grant you a more timely response. |
StefanieSenger
left a comment
There was a problem hiding this comment.
Hello @SuccessMoses,
thanks for picking the PR up and finishing it. I looked through and have added a few review comments. Especially, we should keep the public function names in the examples section to not expose private functions.
| :func:`~metrics.pairwise.paired_euclidean_distances`, | ||
| :func:`~metrics.pairwise.paired_manhattan_distances` and | ||
| :func:`~metrics.pairwise.paired_cosine_distances` are now deprecated and | ||
| will be removed in 1.9. By :user:`Success Moses <SuccessMoses>`. |
There was a problem hiding this comment.
| will be removed in 1.9. By :user:`Success Moses <SuccessMoses>`. | |
| will be removed in 1.9. By :user:`Success Moses <SuccessMoses>` and | |
| :user:`Shreesha Kumar Bhat<Shreesha3112>`. |
Let's also mention @Shreesha3112, who had done the first PR this one is based on.
| >>> from sklearn.metrics.pairwise import paired_euclidean_distances | ||
| >>> from sklearn.metrics.pairwise import _paired_euclidean_distances | ||
| >>> X = [[0, 0, 0], [1, 1, 1]] | ||
| >>> Y = [[1, 0, 0], [1, 1, 0]] | ||
| >>> paired_euclidean_distances(X, Y) | ||
| >>> _paired_euclidean_distances(X, Y) |
There was a problem hiding this comment.
I would leave that as it was, for two reasons:
- There is no need, since users can still use these functions as they were until they get removed .
- We should not expose our internal functions to users in the API docs, because these can be subject of change in the future and we want to be able to do that without a deprecation cycle.
This comment is applicable to all of the 4 deprecated functions.
| # TODO(1.9): Remove PAIRED_DISTANCES dictionary since pairwise_*_distance public | ||
| # functions are deprecated in 1.9 |
There was a problem hiding this comment.
I think I would tend to keep PAIRED_DISTANCES and not go through the renaming (so we don't need to change the imports in other files). The mention of this dict will be gone after removing the functions that use them from the public API anyways.
| "sklearn.metrics.pairwise.paired_cosine_distances", | ||
| "sklearn.metrics.pairwise.paired_distances", | ||
| "sklearn.metrics.pairwise.paired_euclidean_distances", | ||
| "sklearn.metrics.pairwise.paired_manhattan_distances", |
There was a problem hiding this comment.
I don't really mind, just wanted to comment on that: A leaner way would be to use ignore_warnings from sklearn/utils/_testing.py that can also be used as a context manager and it could be done in the same testing function. It doesn't really matter in a practical sense, but would be the more conventional way in scikit-learn.
| "The public function `sklearn.pairwise.paired_euclidean_distances` has been " | ||
| "deprecated in 1.7 and will be removed in 1.9." | ||
| ) | ||
| @validate_params( |
There was a problem hiding this comment.
We could consider to also apply the validate_params() decorator on the private functions, but it doesn't matter so much.
| # Paired distances | ||
|
|
||
|
|
||
| # TODO(1.9): Remove in 1.9 |
There was a problem hiding this comment.
Now, the versions in this whole PR have to be changed from 1.7 for deprecation to 1.8 and from 1.9 for removal to 1.10.
|
Hi @SuccessMoses, are you still working on this? |
Deprecates `paired_distances`, `paired_euclidean_distances`, `paired_manhattan_distances` and `paired_cosine_distances` in 1.10; removal scheduled for 1.12. Internal callers now use module-private `_paired_*` helpers to avoid triggering the deprecation warnings on their own use. The `PAIRED_DISTANCES` dict is kept (same name) and repointed to the private implementations. Continues the stalled work in scikit-learn#30537 (originally based on scikit-learn#27129). Co-authored-by: Success Moses <[email protected]> Co-authored-by: Shreesha Kumar Bhat <[email protected]>
Reference Issues/PRs
This PR is continues the stalled #27129 (closes #27129). And fixes #26982.
What does this implement/fix? Explain your changes.
Deprecates
metrics.pairwise.paired_*_distancefunctions andmetrics.pairwise.paired_distance.Any other comments?
This may be required for #26961