gpt4 book ai didi

python - 导入错误 : cannot import name 'det_curve' from 'sklearn.metrics'

转载 作者:行者123 更新时间:2023-12-05 09:31:15 29 4
gpt4 key购买 nike

不知道为什么会报错,引用官方文档
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.det_curve.html#sklearn.metrics.det_curve

代码:

import numpy as np
from sklearn.metrics import det_curve

fpr, fnr, thresholds = det_curve(y_test, y_pred)
print(fpr, fnr, thresholds)

错误:

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-46-d8d6f0b546ca> in <module>()
10
11 import numpy as np
---> 12 from sklearn.metrics import det_curve
13
14 fpr, fnr, thresholds = det_curve(y_test['cEXT'], y_pred)

ImportError: cannot import name 'det_curve' from 'sklearn.metrics' (/usr/local/lib/python3.7/dist-packages/sklearn/metrics/__init__.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

最佳答案

我的 Jupyter notebook 也遇到了同样的问题。我卸载并重新安装了 scikit-learn 和 imblearn。它没有用。然后重启内核,再次运行,问题解决。

关于python - 导入错误 : cannot import name 'det_curve' from 'sklearn.metrics' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68964555/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com