在调试模式下,sklearn' s roc_auc_score错误,但正常运行时运行良好?

发布于 2025-02-12 07:28:54 字数 2154 浏览 1 评论 0原文

我正在使用roc_auc_score来评估两个数组之间的AUC,即真相和估计。当我正常在Pycharms上执行该代码时,我的代码运行正常;但是,当我使用调试模式时,以下奇怪的错误弹出。我尝试在roc_auc_score行之前暂停代码,并尝试使用仅使用2个小数组的调试控制台运行它。同样的问题。奇怪的是,使用普通Python控制台一切都很好。有什么想法吗?

Traceback (most recent call last):
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\numpy\core\getlimits.py", line 649, in __init__
    self.dtype = numeric.dtype(int_type)
TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2022.1.2\plugins\python\helpers\pydev\pydevd.py", line 1491, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2022.1.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/User/PycharmProjects/project/main-resnet.py", line 707, in <module>
    results = train_net(net=net,
  File "C:/Users/User/PycharmProjects/project/main-resnet.py", line 495, in train_net
    train_auc = roc_auc_score(training_true, training_estimated)
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\sklearn\metrics\_ranking.py", line 566, in roc_auc_score
    y_true = label_binarize(y_true, classes=labels)[:, 0]
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\sklearn\preprocessing\_label.py", line 546, in label_binarize
    Y = sp.csr_matrix((data, indices, indptr), shape=(n_samples, n_classes))
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\scipy\sparse\compressed.py", line 66, in __init__
    idx_dtype = get_index_dtype((indices, indptr),
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\scipy\sparse\sputils.py", line 153, in get_index_dtype
    int32min = np.iinfo(np.int32).min
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\numpy\core\getlimits.py", line 651, in __init__
    self.dtype = numeric.dtype(type(int_type))
TypeError: 'NoneType' object is not callable
python-BaseException

I'm using roc_auc_score to evaluate AUC between two arrays, the truth and the estimation. My code runs fine when I'm executing it normally on PyCharms; however, when I use the debug mode, the below strange errors pop up. I tried pausing the code prior to the roc_auc_score line and attempted to just run it using the debug console with just 2 small arrays. Same issue. Strangely, everything is fine using the normal Python console. Any ideas?

Traceback (most recent call last):
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\numpy\core\getlimits.py", line 649, in __init__
    self.dtype = numeric.dtype(int_type)
TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2022.1.2\plugins\python\helpers\pydev\pydevd.py", line 1491, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2022.1.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/User/PycharmProjects/project/main-resnet.py", line 707, in <module>
    results = train_net(net=net,
  File "C:/Users/User/PycharmProjects/project/main-resnet.py", line 495, in train_net
    train_auc = roc_auc_score(training_true, training_estimated)
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\sklearn\metrics\_ranking.py", line 566, in roc_auc_score
    y_true = label_binarize(y_true, classes=labels)[:, 0]
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\sklearn\preprocessing\_label.py", line 546, in label_binarize
    Y = sp.csr_matrix((data, indices, indptr), shape=(n_samples, n_classes))
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\scipy\sparse\compressed.py", line 66, in __init__
    idx_dtype = get_index_dtype((indices, indptr),
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\scipy\sparse\sputils.py", line 153, in get_index_dtype
    int32min = np.iinfo(np.int32).min
  File "C:\Users\User\anaconda3\envs\project\lib\site-packages\numpy\core\getlimits.py", line 651, in __init__
    self.dtype = numeric.dtype(type(int_type))
TypeError: 'NoneType' object is not callable
python-BaseException

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨落成白 2025-02-19 07:28:54

好吧...猜猜我只是在谷歌搜索错误的事情:P

这似乎是Pycharms和Python版本之间的问题( https://youtrack.jetbrains.com/issue/py-52137 )。

从Python 3.10.1转换为3.9应该可以工作。

Well... guess I was simply googling the wrong thing :P

It seems to be an issue between PyCharms and the python version (https://youtrack.jetbrains.com/issue/PY-52137).

Switching from Python 3.10.1 to 3.9 should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文