-
-
Notifications
You must be signed in to change notification settings - Fork 26k
MNT Deprecate metrics.pairwise.paired_*_distances and paired_distances public functions #30537
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
base: main
Are you sure you want to change the base?
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. |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@deprecated( | ||
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could consider to also apply the validate_params()
decorator on the private functions, but it doesn't matter so much.
@@ -1187,6 +1187,13 @@ def cosine_distances(X, Y=None): | |||
|
|||
|
|||
# Paired distances | |||
|
|||
|
|||
# TODO(1.9): Remove in 1.9 |
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.
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.
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_*_distance
functions andmetrics.pairwise.paired_distance
.Any other comments?
This may be required for #26961