5

Here is my import lines:

from sklearn.metrics import PrecisionRecallDisplay

When I type

PrecisionRecallDisplay

I get

sklearn.metrics._plot.precision_recall_curve.PrecisionRecallDisplay

insted of

sklearn.metrics.PrecisionRecallDisplay

I am trying to run the following code line:

display = PrecisionRecallDisplay.from_estimator(lr_clf, x_test, y_test, name = "Logistic Regression")

and I get this error:

AttributeError: type object 'PrecisionRecallDisplay' has no attribute 'from_estimator'

I am using the latest version of sklearn.('0.24.2')

2 Answers 2

6

0.24.2 is not the latest version of scikit-learn—as of this writing, version 1.0 was released two days ago. You will need to upgrade to that version to use PrecisionRecallDisplay.from_estimator because the the 0.24.2 release predates the addition of PrecisionRecallDisplay.from_estimator by a few months.

If you are using conda, you can upgrade with

conda upgrade -c conda-forge scikit-learn

or, with pip,

python -m pip install scikit-learn --upgrade
1
  • 4
    I'm on scikit_learn 1.0.2 and still getting this error. Commented Jan 11, 2022 at 0:14
0

As it has been mentioned, an update to version 1.0 at least is needed.

You can either use for conda,

conda upgrade -c conda-forge scikit-learn

or for pip

python -m pip install scikit-learn --upgrade

(if it still does not work) MY UPDATE:

I have been struggling for time and deleting previous scikit-learn from my environment and installing again solved the issue:

pip uninstall scikit-learn

then follow the same example above for installation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.