question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

plot_roc_curve doesn't correctly infer pos_label

See original GitHub issue
from 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:closed
  • Created 4 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
thomasjpfancommented, Oct 29, 2019

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 that pos_label appears in est.classes_.

0reactions
amuellercommented, Nov 6, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found