Python 的 fastText:计算精度

fastText with Python: Calculate Accuracy

我正在使用 fastText with Python,它提供精确度和召回率,但不提供准确性。如何从 fastText 获得准确性?或者,或者,如何计算给定精度和召回率的准确性?

我做了这段代码,从 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()