gpt4 book ai didi

python - 我无法绘制以下数据 : (Precision-Recall curve)

转载 作者:行者123 更新时间:2023-11-28 18:45:35 25 4
gpt4 key购买 nike

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

      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 以下的区域是否正常?

enter image description here

最佳答案

这似乎是正确的答案。

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

关于python - 我无法绘制以下数据 : (Precision-Recall curve),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20705968/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com