IndexError:尝试使用rdkit计算AUC度量时,标量变量的索引无效

2024-09-30 00:25:37 发布

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

我想用rdkit实现计算ROC曲线:

rdkit.ML.Scoring.Scoring.calcuc(分数,col)

确定ROC曲线下的面积

代码:

import rdkit.ML.Scoring.Scoring

rdkit.ML.Scoring.Scoring.CalcAUC(scores, y)

我得到以下错误:

IndexError: invalid index to scalar variable.

我的数据:

scores

array([32.336, 31.894, 31.74 , ..., -0.985, -1.629, -1.82 ])

y

array(['Inactive', 'Inactive', 'Inactive', ..., 'Inactive', 'Inactive','Inactive'], dtype=object)

我不知道怎么了


Tags: 代码importcolarrayml曲线分数roc
1条回答
网友
1楼 · 发布于 2024-09-30 00:25:37
from rdkit.ML.Scoring.Scoring import CalcAUC
scores = [32.336, 31.894, 31.74, 30., 20.]  # assume scores is sorted in descending order
y = ['Inactive', 'Inactive', 'Inactive', 'Active', 'Inactive']

label_map = {'Active': 1, 'Inactive': 0}
labels = [label_map[y_true] for y_true in y]
auc = CalcAUC(list(zip(scores, labels)), 1)
print('Area Under the ROC Curve:', auc)

如上述评论所述。CalcAUC和其他度量的文档是here,但非常少

相关问题 更多 >

    热门问题