【问题标题】:I can't plot the following data : (Precision-Recall curve)我无法绘制以下数据:(Precision-Recall 曲线)
【发布时间】:2014-01-09 10:54:05
【问题描述】:

您好,我正在尝试使用以下数据绘制召回精度曲线:

      Recall    Precision
0.88196 0.467257
0.898501    0.468447
0.89899 0.470659
0.900789    0.471653
0.900922    0.472038
0.901012    0.472359
0.901345    0.480144
0.901695    0.482353
0.902825    0.482717
0.903261    0.483125
0.905152    0.483621
0.905575    0.485088
0.905682    0.486339
0.906109    0.488117
0.906466    0.488459
0.90724 0.488587
0.908989    0.488875
0.909941    0.489362
0.910125    0.489493
0.910314    0.490196
0.910989    0.49022
0.91106 0.490786
0.911137    0.496624
0.91129 0.496891
0.911392    0.497301
0.911392    0.499379
0.911422    0.5
0.911452    0.503783
0.911525    0.515829

源代码:

import random
import pylab as pl
from sklearn import svm, datasets
from sklearn.metrics import precision_recall_curve
from sklearn.metrics import auc

##Load Recall
fname = "recall.txt"
fname1 = "precision.txt"

recall = []
precision = []

with open(fname) as inf:
    for line in inf:
        recall.append(float(line))

with open(fname1) as inf:
    for line in inf:
        precision.append(float(line))

area = auc(recall, precision)
print("Area Under Curve: %0.2f" % area)

pl.clf()
pl.plot(recall, precision, label='Precision-Recall curve')
pl.xlabel('Recall')
pl.ylabel('Precision')
pl.ylim([0.0, 1.05])
pl.xlim([0.0, 1.0])
pl.title('Precision-Recall example: AUC=%0.2f' % area)
pl.legend(loc="lower left")
pl.show()

我得到的面积低于 AUC = 0.01 是正常的吗?

【问题讨论】:

    标签: python statistics precision-recall


    【解决方案1】:

    这似乎是正确的答案。

    使用numpy.trapz(precission, recall) 我得到AUC = 0.014036223712000031

    【讨论】:

    • 这就是我的想法@plover。谢谢,其实我错了
    猜你喜欢
    • 2021-05-19
    • 2021-07-31
    • 2014-12-22
    • 2017-01-23
    • 2018-02-23
    • 2015-10-03
    • 2020-04-05
    • 1970-01-01
    相关资源
    最近更新 更多