sklearn函数“RocCurveDisplay”没有“from_predictions”属性的错误消息

2024-09-30 14:37:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用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


Tags: 函数fromhttpsorgtruenpsklearnscikit