Farzaneh
Farzaneh

Reputation: 188

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

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

Upvotes: 5

Views: 5675

Answers (2)

Javiagu13
Javiagu13

Reputation: 86

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.

Upvotes: 0

Andrew Tapia
Andrew Tapia

Reputation: 1466

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

Upvotes: 6

Related Questions