如何确定ROC图的端点

2024-09-28 22:25:52 发布

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

我已经创建了ROC图。但它和正常的不同。你知道吗

通常的ROC图:

The usual ROC graph

我的ROC图:

My ROC graph

    #!/usr/bin/env python

import matplotlib.pyplot as plt
# Import the data from output file
#from output import *
from output1 import *

plt.figure('All Profile')
plt.title('Receiver Operating Characteristic (ROC)')
plt.ylim(ymax = 1.0000, ymin = 0.0000)
plt.xlim(xmax = 1.0000, xmin = 0.0000)
plt.ylabel('True Positive Rate (TPR)')
plt.xlabel('False Positive Rate (FPR)')
plt.grid(True)
# The diagonal line
x = [0.0, 1.0]
plt.plot(x, x, linestyle='dashed', color='red', linewidth=2, label='random')

# FPRlist and TPRlist the variable that save the data in output file
plt.plot(FPRlist, TPRlist, linewidth=2,  marker='o', color='b')
plt.show()

这是我保存在output1.py中的数据

TPRlist=['0.995', '0.989', '0.972', '0.799', '0.317', '0.198', '0.071', '0.000', '0.000', '0.000', '0.000', '0.000', '0.000', '0.000', '0.000']
FPRlist=['0.487', '0.475', '0.465', '0.292', '0.143', '0.085', '0.001', '0.000', '0.000', '0.000', '0.000', '0.000', '0.000', '0.000', '0.000']

那我该怎么办?是不是因为我的数据,我得到了这样的图表?你知道吗


Tags: thefromimporttrueoutputdatarateplot
2条回答

如果您的意思是ROC的某些部分正好与轴限制重合,那么您可以在plt.show()之前简单地写下:

plt.ylim(-0.005, 1.005)
plt.xlim(-0.005, 1.005)

ROC的输入数据通常包含两个非常简单的操作点:

  1. 所有样品均归类为阴性,TPR=0和FPR=0
  2. 所有样本均为阳性,TPR=1和FPR=1

相关问题 更多 >