【发布时间】:2019-10-08 18:25:09
【问题描述】:
我在 keras 中训练了一个模型,并做出了一些预测。为了评估我的模型的性能,我使用 sklearn 库计算了精度和召回分数以及混淆矩阵。这是我的代码:
final_predictions = model.predict_generator(generator_test, steps=steps_per_epoch_test)
rounded_pred = [0 if x<=0.5 else 1 for x in final_predictions]
test_precision_score = round(precision_score(y_test, rounded_pred), 3)
test_recall_score = round(recall_score(y_test, rounded_pred), 3)
test_confusion_matrix = confusion_matrix(y_test, rounded_pred)
这些是我的结果:
Test confusion matrix :
[[1555 13]
[ 9 49]]
Precision and recall:
Test Precision :: 0.845
Test Recall :: 0.79
有人知道为什么精度分数计算不正确吗? (应该是(1555/(1555+13) 而不是(13/(13+49)))
【问题讨论】:
-
你有没有试过切换
confusion_matrix()的参数。在我看来,准确率和召回率是用 49 被视为真阳性而不是真阴性来计算的。
标签: scikit-learn neural-network artificial-intelligence metrics