Python、Pandas、および NLTK を使用して Naive Bayes 分類器を実行しています。
一般に、適合率と再現率を計算する対象と方法は理解していますが、次のコマンドを使用するときに、適合率と再現率のペアが 1 組ある理由がわかりません。
from featx import precision_recall
nb_precisions, nb_recalls = precision_recall(nb_classifier, test_feats)
training_n = int(data_n * 0.25) ### changeable
featuresets = [(first_letter(name), ethnicity) for index, (name, ethnicity, last_name) in df.iterrows()] ### changeable
train_feats, test_feats = featuresets[training_n:], featuresets[:training_n]
nb_classifier = NaiveBayesClassifier.train(train_feats)
# Performance
print "Accuracy: " + str(accuracy(nb_classifier, test_feats))
# Precision and recall
nb_precisions, nb_recalls = precision_recall(nb_classifier, test_feats)
print "Precision +: " + str(nb_precisions[ethnic_target1])
print "Precision -: " + str(nb_precisions[ethnic_non_target])
print "Recall +: " + str(nb_recalls[ethnic_target1])
print "Recall -: " + str(nb_recalls[ethnic_non_target])
Accuracy: 0.99632
Precision +: None
Precision -: 0.99632
Recall +: 0.0
Recall -: 1.0
分類は人名の頭文字(特徴)で中国人と非中国人。
Gold standard
Chinese non-Chinese
Predicted Chinese A C
non-Chinese B D
私の理解では、適合率 = A/(A+C) および再現率 = D/(B+D) です。