Jul*_*the 6 python roc scikit-learn
我正在尝试使用https://scikit-learn.org/stable/modules/ generated/sklearn.metrics.RocCurveDisplay.html#sklearn.metrics.RocCurveDisplay.from_predictions 中介绍的 sklearn 函数 RocCurveDisplay.from_predictions 。我像这样运行该函数:
from sklearn.metrics import RocCurveDisplay
true = np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1., 1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0.])
prediction = np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0., 0., 0.,
1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 1., 1., 0., 0.])
RocCurveDisplay.from_predictions(true,prediction)
plt.show()
Run Code Online (Sandbox Code Playgroud)
我收到错误消息“AttributeError:类型对象‘RocCurveDisplay’没有属性‘from_predictions’”。
这是版本问题吗?我使用的是最新的0.24.1
您的版本0.24.1不是最新版本,您需要升级到 scikit-learn ,1.0如from_predictions1.0
您可以使用以下方式升级:
pip install --upgrade scikit-learn
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11163 次 |
| 最近记录: |