我将fastText 与 Python 一起使用,它提供了精度和召回率,但不提供准确性。如何从 fastText 获得准确性?或者,在给定精度和召回率的情况下,我如何计算准确率?
问问题
810 次
1 回答
0
我做了这段代码,从 CSV 中的一行中获取数据(从标签开始)并与预测进行比较,然后保存在 .txt 中
f = open('accuracy.txt', 'w')
total, correct = 0, 0
for idx, row in X.iteritems():
#Getting data from a CSV
line = row.split()
label = line[0]
description = " ".join(line[1:])
#Predicting
predict = model.predict(description , k=1)
#Saving accuracy
total += 1
if(predict[0][0] == label):
correct += 1
f.writelines("Accuracy = " + str(correct/total) + '\n')
f.close()
于 2019-07-26T18:14:32.520 回答