Skip to content
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

Update Sklearn API plot_roc_curve -> RocCurveDisplay #45

Open
mrdbourke opened this issue Feb 9, 2023 · 2 comments
Open

Update Sklearn API plot_roc_curve -> RocCurveDisplay #45

mrdbourke opened this issue Feb 9, 2023 · 2 comments

Comments

@mrdbourke
Copy link
Owner

mrdbourke commented Feb 9, 2023

Link to notebook changed: https://github.com/mrdbourke/zero-to-mastery-ml/blob/master/section-3-structured-data-projects/end-to-end-heart-disease-classification.ipynb

Error

As of Scikit-Learn 1.2+ the method sklearn.metrics.plot_roc_curve is deprecated in favour of sklearn.metrics.RocCurveDisplay.

How to check your Scikit-Learn version

You can check your Scikit-Learn version with:

import sklearn
sklearn.__version__

How to update your Scikit-Learn version

You can run the following command in your terminal with your Conda (or other) environment active to upgrade Scikit-Learn (the -U stands for "upgrade):

pip install -U scikit-learn

Previous code (this will error if running Scikit-Learn version 1.2+)

# This will error if run in Scikit-Learn version 1.2+
from sklearn.metrics import plot_roc_curve

Also:

# This will error if run in Scikit-Learn version 1.2+
from sklearn.metrics import plot_roc_curve 
plot_roc_curve(gs_log_reg, X_test, y_test);

New code (this will work with Scikit-Learn version 1.2+)

from sklearn.metrics import RocCurveDisplay # new in Scikit-Learn 1.2+

And to plot a ROC curve, note the use of RocCurveDisplay.from_estimator():

# Scikit-Learn 1.2.0 or later
from sklearn.metrics import RocCurveDisplay 

# from_estimator() = use a model to plot ROC curve on data
RocCurveDisplay.from_estimator(estimator=gs_log_reg, 
                               X=X_test, 
                               y=y_test); 

Screenshot 2023-02-23 at 4 31 34 pm

@Dhrubaraj-Roy
Copy link

Thank you!!!

@kRiShNa-429407
Copy link

Thank you

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

No branches or pull requests

3 participants