我有以下测试值:
y_test2 = [0, 0, 1, 1]
以及以下预测值:
y_pred2 = [1, 0, 1, 1]
所以我有一个以{0,1}
为类的二进制分类问题。
如果我使用sklearnconfusion_matrix
:
confusion_matrix(y_test2, y_pred2)
array([[1, 1], #one 0 was predicted as 0 (TruePositive), one 0 was predicted as 1 (FalseNegative)
[0, 2]], dtype=int64) #two 1 were predicted as 1 (TrueNegatives)
所以对我来说:
TP: 1
FN: 1
TN: 2
FP: 0
但是,当我用ravel运行confusion\u矩阵时,我学习了以下文档:
tn, fp, fn, tp = confusion_matrix(y_test2, y_pred2).ravel()
(1, 1, 0, 2)
为什么scikit将1解释为真值?为什么文档中没有提到:https://scikit-learn.org/stable/modules/generated/sklearn.metrics.confusion_matrix.html 对于使用命名约定的二进制分类,我还可能面临其他问题吗?有机会避免吗
请看documentation中的描述:
所以从你的阵列
是的
相关问题 更多 >
编程相关推荐