Skip to content

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

Closed
wants to merge 13 commits into from
Closed

MAINT Parameters validation for sklearn.metrics.average_precision_score #25313

wants to merge 13 commits into from

Conversation

dlitsidis
Copy link
Contributor

Reference Issues/PRs

Towards #24862

Added the validate_params decorator for sklearn.metrics.average_precision_score

Copy link
Member

@glemaitre glemaitre left a 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(
Copy link
Member

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",
Copy link
Member

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"],
Copy link
Member

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

{
"y_true": ["array-like"],
"y_score": ["array-like"],
"average": [StrOptions({"micro", "samples", "weighted", "macro"})],
Copy link
Member

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],

"y_true": ["array-like"],
"y_score": ["array-like"],
"average": [StrOptions({"micro", "samples", "weighted", "macro"})],
"pos_label": [Integral, str, 1],
Copy link
Member

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"],

@dlitsidis
Copy link
Contributor Author

dlitsidis commented Jan 6, 2023

ok i think i made the right updates for average_precision_score function

@dlitsidis
Copy link
Contributor Author

How can i revert a file that is already merged?

@glemaitre
Copy link
Member

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

@dlitsidis
Copy link
Contributor Author

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

@glemaitre
Copy link
Member

One PR should only make changes for one of the function. Here, you are updating both fetch_california_housing and average_precision_score. You need to only change average_precision_score. We don't want the changes of fetch_california_housing. Those changes should be done in another branch and thus another PR.

@dlitsidis
Copy link
Contributor Author

dlitsidis commented Jan 6, 2023

So can i just close this pull request as it is and make a new one only with the change of average_precision_score?

@glemaitre
Copy link
Member

So can i just close this pull request as it is an 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.

@dlitsidis
Copy link
Contributor Author

ok so i am closing this pull request

@dlitsidis dlitsidis closed this Jan 6, 2023
@dlitsidis dlitsidis deleted the <param-valid> branch January 6, 2023 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants