1.4.3 准确率与召回率
机器学习中最基本的指标是召回率(recall rate)和准确率(precision rate),召回率也叫查全率,准确率也叫查准率。
召回率=tp/(tp+fn)
准确率=tp/(tp+fp)
举例来解释这两个枯燥的概念。一个池塘有10条鱼和20只小龙虾,渔夫撒网打鱼,结果捞上来8条鱼和12只小龙虾,那么准确率为8/(8+12)=40%,召回率为8/10=80%。
在scikit-learn中,可以使用如下代码获得准确率和召回率:
print "recall_score:"
print metrics.recall_score(test_y, pred_y)
print "precision_score:"
print metrics.precision_score(test_y, pred_y)
输出结果如下,其中召回率为65.71%,准确率为73.40%:
recall_score:
0.657142857143
precision_score:
0.734042553191