Thanks to visit codestin.com
Credit goes to github.com

Skip to content

plot_precision_recall_curve should expose pos_label #17565

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
glemaitre opened this issue Jun 11, 2020 · 3 comments · Fixed by #17569
Closed

plot_precision_recall_curve should expose pos_label #17565

glemaitre opened this issue Jun 11, 2020 · 3 comments · Fixed by #17569

Comments

@glemaitre
Copy link
Member

I think that we should expose the pos_label as one of the parameters of plot_precision_recall_curve. I even think that we should issue a warning in case of class imbalance and that the positive class considered is the one with most samples. In most of cases, you are reporting the wrong part of your result but it might be what we give as a result with defaults.

import pandas as pd
from sklearn.datasets import fetch_openml
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import plot_precision_recall_curve

X, y = fetch_openml(
    name="blood-transfusion-service-center",
    as_frame=True, return_X_y=True,
)
# Make columns and classes more human-readable
X.columns = ["Recency", "Frequency", "Monetary", "Time"]
y = y.apply(
    lambda x: "donated" if x == "2" else "not donated"
).astype("category")

X_train, X_test, y_train, y_test = train_test_split(
    X, y, shuffle=True, random_state=0, test_size=0.5
)

classifier = LogisticRegression().fit(X_train, y_train)
plot_precision_recall_curve(classifier, X_test, y_test)

pr_curve

@glemaitre
Copy link
Member Author

I would even say this is a bug because I don't have any way to change the plot indeed :)

@glemaitre
Copy link
Member Author

related to #15573

@glemaitre
Copy link
Member Author

I am closing this issue because the discussion needs to happen in #15573

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant