plot_roc_curve doesn't correctly infer pos_label
See original GitHub issuefrom sklearn.metrics import plot_roc_curve
from sklearn.datasets import make_blobs
from sklearn.linear_model import LogisticRegression
import numpy as np
X, y = make_blobs(centers=2)
y = y.astype(np.str)
lr = LogisticRegression().fit(X, y)
plot_roc_curve(lr, X, y)
-> raise ValueError("Data is not binary and pos_label is not specified")
I would argue that pos_label=lr.classes_[1]
is the right choice here.
cc @thomasjpfan
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (17 by maintainers)
Top Results From Across the Web
roc_curve in sklearn: why doesn't it work correctly?
I want to understand, why roc curve for binary classes and roc curve with "positive label" look different and how to plot roc...
Read more >sklearn.metrics.RocCurveDisplay
Plot ROC curve given the true and predicted values. ... If set to 'auto', predict_proba is tried first and if it does not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In this case, since we have the trained estimator, we can infer the pos_label from
est.classes_[1]
as suggested above.If a user wants to pass another
pos_label
we can make sure thatpos_label
appears inest.classes_
.See my comment in https://github.com/scikit-learn/scikit-learn/pull/15405#issuecomment-550482262 please. I was a bit confused about what is happening.