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

Skip to content

[MRG] BUG Remove pos_label in plot_roc_auc_curve #15555

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

Merged

Conversation

thomasjpfan
Copy link
Member

Reference Issues/PRs

Resolves #15405
Alternative to #15316
Alternative to #15405

What does this implement/fix? Explain your changes.

Remove pos_label from plot_roc_auc_curve and always infer from the estimator.

Any other comments?

Three PRs one issue :/

CC @amueller

@thomasjpfan thomasjpfan changed the title BUG Remove pos_label in plot_roc_auc_curve [MRG] BUG Remove pos_label in plot_roc_auc_curve Nov 6, 2019

if is_classifier(estimator):
if len(estimator.classes_) != 2:
raise ValueError(classificaiton_error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ValueError(classificaiton_error)
raise ValueError(classification_error)

Copy link
Member

@amueller amueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good apart from typo.

Can you open a follow-up issue?

Copy link
Member

@qinhanmin2014 qinhanmin2014 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this is actually my solution at the beginning

@qinhanmin2014 qinhanmin2014 merged commit d847557 into scikit-learn:master Nov 7, 2019
@ogrisel
Copy link
Member

ogrisel commented Nov 7, 2019

@qinhanmin2014's PR #15316 also had additional tests for plot_roc_curve that covers things not covered in this version.

@ogrisel
Copy link
Member

ogrisel commented Nov 7, 2019

def test_plot_roc_curve_pos_label(pyplot, data_binary):
    X, y = data_binary
    y = np.array(["neg", "pos"])[y]
    lr = LogisticRegression()
    lr.fit(X, y)
    y_pred = lr.predict_proba(X)[:, 1]
    viz = plot_roc_curve(lr, X, y)
    assert_allclose(viz.roc_auc, roc_auc_score(y, y_pred))


def test_plot_roc_curve_pos_label_non_standard_integers(pyplot, data_binary):
    X, y = data_binary
    y = np.array([1, 2])[y]
    lr = LogisticRegression()
    lr.fit(X, y)
    y_pred = lr.predict_proba(X)[:, 1]
    viz = plot_roc_curve(lr, X, y)
    assert_allclose(viz.roc_auc, roc_auc_score(y, y_pred))

@qinhanmin2014
Copy link
Member

I'll open a PR but I guess that's not so important.

@qinhanmin2014
Copy link
Member

@ogrisel Thomas already updates test_plot_roc_curve to include a very similar test. Do you think that's enough?

def test_plot_roc_curve(pyplot, response_method, data_binary,

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

Successfully merging this pull request may close these issues.

4 participants