-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
MAINT Parameters validation for sklearn.metrics.average_precision_score #25313
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.
A couple of comment.
@@ -50,6 +51,14 @@ | |||
logger = logging.getLogger(__name__) | |||
|
|||
|
|||
@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.
I think that this changes should be done in another PR. Could you revert this file.
@@ -100,13 +100,15 @@ def _check_function_param_validation( | |||
"sklearn.cluster.kmeans_plusplus", | |||
"sklearn.covariance.empirical_covariance", | |||
"sklearn.covariance.shrunk_covariance", | |||
"sklearn.datasets.fetch_california_housing", |
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.
Can you revert this change.
@@ -112,6 +112,15 @@ def auc(x, y): | |||
return area | |||
|
|||
|
|||
@validate_params( | |||
{ | |||
"y_true": ["array-like"], |
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.
It is true that we are going to call column_or_1d
that will transform any array-like into a NumPy array. Could you update the docstring of y_true
and y_score
to change ndarray
by array-like
sklearn/metrics/_ranking.py
Outdated
{ | ||
"y_true": ["array-like"], | ||
"y_score": ["array-like"], | ||
"average": [StrOptions({"micro", "samples", "weighted", "macro"})], |
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.
It seems that None is also an option
"average": [StrOptions({"micro", "samples", "weighted", "macro"}), None],
sklearn/metrics/_ranking.py
Outdated
"y_true": ["array-like"], | ||
"y_score": ["array-like"], | ||
"average": [StrOptions({"micro", "samples", "weighted", "macro"})], | ||
"pos_label": [Integral, str, 1], |
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.
1 is already an Integral
. However, I don't think that we should be limited to those 2 types since we could have also float classes and boolean. The following seems more appropriate.
"pos_label": [Real, str, "boolean"],
ok i think i made the right updates for average_precision_score function |
How can i revert a file that is already merged? |
There are multiple manners. You can copy-paste the old file and merge again or follow one of those post that you can find on google: https://dev.to/lofiandcode/git-and-github-how-to-revert-a-single-file-dha |
i am sorry to asking again but it gets complicated to my head, i think in this pull request i have change already 3 functions multilabel_comfusion_matrix, det_curve, fetch_california_housing and the last one now.So its not clear right now to me what do you want me to do with all these what exactly to copy from each function and overall what to change first |
One PR should only make changes for one of the function. Here, you are updating both |
So can i just close this pull request as it is and make a new one only with the change of average_precision_score? |
It works as well. Feel free to take the easier path for you. |
ok so i am closing this pull request |
Reference Issues/PRs
Towards #24862
Added the validate_params decorator for sklearn.metrics.average_precision_score