不同的结果 roc_auc_score 和 plot_roc_curve [英] Different result roc_auc_score and plot_roc_curve

查看:144
本文介绍了不同的结果 roc_auc_score 和 plot_roc_curve的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在训练一个 RandomForestClassifier (sklearn) 来预测信用卡欺诈.当我测试模型并检查 rocauc 分数时,当我使用 roc_auc_scoreplot_roc_curve 时,我得到了不同的值.roc_auc_score 给我大约 0.89,而 plot_curve 计算出的 AUC 为 0.96,这是为什么?

I am training a RandomForestClassifier (sklearn) to predict credit card fraud. When I then test the model and check the rocauc score i get different values when I use roc_auc_score and plot_roc_curve. roc_auc_score gives me around 0.89 and the plot_curve calculates AUC to 0.96 why is that?

标签都是 0 和 1,预测是 0 或 1.代码:

The labels are all 0 and 1 as well as the predictions are 0 or 1. CodE:

clf = RandomForestClassifier(random_state =42)
clf.fit(X_train, y_train[target].values)
pred_test = clf.predict(X_test)
print(roc_auc_score(y_test, pred_test))
clf_disp = plot_roc_curve(clf, X_test, y_test)
plt.show()

代码的输出(roc_auc_Score 就在图表上方).

Output of the code (the roc_auc_Score is just above the graph).

推荐答案

ROC 曲线和 roc_auc_score 将预测概率作为输入,但正如我从您的代码中看到的,您提供的是预测标签.你需要解决这个问题.

The ROC Curve and the roc_auc_score take the prediction probabilities as input, but as I can see from your code you are providing the prediction labels. You need to fix that.

这篇关于不同的结果 roc_auc_score 和 plot_roc_curve的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆