我试图使用sklearn函数RocCurveDisplay.from_预测,如https://scikit-learn.org/stable/modules/generated/sklearn.metrics.RocCurveDisplay.html#sklearn.metrics.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()
我收到错误消息“AttributeError:type对象'RocCurveDisplay'没有'from'属性”
这是版本问题吗?我使用的是最新的0.24.1
您的版本
0.24.1
不是最新版本,您需要升级到scikit学习1.0
,因为1.0
中支持from_predictions
您可以使用以下方式升级:
相关问题 更多 >
编程相关推荐