AttributeError:类型对象“PrecisionRecallDisplay”没有属性“from_estimator”

Far*_*neh 5 python-3.x scikit-learn

这是我的导入行:

from sklearn.metrics import PrecisionRecallDisplay
Run Code Online (Sandbox Code Playgroud)

当我打字时

PrecisionRecallDisplay
Run Code Online (Sandbox Code Playgroud)

我明白了

sklearn.metrics._plot.precision_recall_curve.PrecisionRecallDisplay
Run Code Online (Sandbox Code Playgroud)

插入的

sklearn.metrics.PrecisionRecallDisplay
Run Code Online (Sandbox Code Playgroud)

我正在尝试运行以下代码行:

display = PrecisionRecallDisplay.from_estimator(lr_clf, x_test, y_test, name = "Logistic Regression")
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

AttributeError: type object 'PrecisionRecallDisplay' has no attribute 'from_estimator'
Run Code Online (Sandbox Code Playgroud)

我正在使用最新版本的sklearn。('0.24.2')

fak*_*dad 6

0.24.2 不是scikit -learn\xe2\x80\x94 的最新版本,截至撰写本文时,1.0 版本已于两天前发布。您需要升级到该版本才能使用,PrecisionRecallDisplay.from_estimator因为 0.24.2 版本早于添加PrecisionRecallDisplay.from_estimator几个月。

\n

如果您使用的是 conda,则可以使用以下命令进行升级

\n
conda upgrade -c conda-forge scikit-learn\n
Run Code Online (Sandbox Code Playgroud)\n

或者,与pip,

\n
python -m pip install scikit-learn --upgrade\n
Run Code Online (Sandbox Code Playgroud)\n

  • 我正在使用“scikit_learn 1.0.2”,但仍然收到此错误。 (4认同)