Home > Blockchain >  AttributeError: type object 'PrecisionRecallDisplay' has no attribute 'from_estimator
AttributeError: type object 'PrecisionRecallDisplay' has no attribute 'from_estimator

Time:09-27

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')

CodePudding user response:

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
  • Related