简体   繁体   English

如何找到plot ROC曲线的真阳性率和假阳性率?

[英]How to find true positive rate and false positive rate to plot ROC curve?

How to draw a ROC curse using "matplotlib.pyplot".如何使用“matplotlib.pyplot”绘制 ROC 诅咒。 Its x-axis is "False Positive Rate", and y-axis is "True Positive Rate".它的 x 轴是“假阳性率”,y 轴是“真阳性率”。

I have recall and precison with me.我有回忆和精确。 I know recall is true positive rate.我知道召回率是真阳性率。 However i dont know how to find false positive rate to plot ROC curve.但是我不知道如何找到 plot ROC 曲线的误报率。 It becomes easier to plot the curve when i have TPR and FPR with me.当我有 TPR 和 FPR 时,曲线变得更容易 plot。 Here is a snapshot of the dataframe fow which i would like to dinf ROC curve.这是 dataframe 流的快照,我想用它来计算 ROC 曲线。 'label_Num' is the actual value and 'prediction' is the predicted value. 'label_Num' 是实际值,'prediction' 是预测值。

数据框

You could use scikit-learn to generate the values to generate your ROC curve:您可以使用 scikit-learn 来生成生成 ROC 曲线的值:

from sklearn.metrics import roc_curve

fpr, tpr, thresholds = roc_curve(y_true=y_true, y_score=y_pred)
plt.plot(fpr, tpr)

You just need to provide y_true and y_pred, which correspond to label_Num and prediction in your table.您只需要提供 y_true 和 y_pred,它们对应于您表中的 label_Num 和预测。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM