【问题标题】:Error message with sklearn function " 'RocCurveDisplay' has no attribute 'from_predictions' "sklearn 函数的错误消息“'RocCurveDisplay' 没有属性 'from_predictions'”
【发布时间】:2021-10-04 16:35:35
【问题描述】:

我正在尝试使用 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()

我收到错误消息“AttributeError: type object 'RocCurveDisplay' has no attribute 'from_predictions'”。

这是版本问题吗?我正在使用最新的 0.24.1

【问题讨论】:

    标签: python scikit-learn roc


    【解决方案1】:

    您的版本 0.24.1 不是最新版本,您需要升级到 scikit-learn 1.0 因为 from_predictions 支持 1.0

    您可以使用以下方式升级:

    pip install --upgrade scikit-learn
    

    【讨论】:

    • 值得一提的是,该版本仅支持python 3.7及以上版本
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-21
    • 1970-01-01
    • 2018-12-09
    • 1970-01-01
    • 1970-01-01
    • 2013-10-06
    • 1970-01-01
    相关资源
    最近更新 更多