[英]get True Positives, TN, FP and FN for arrays in Python
my data set result look like this我的数据集结果是这样的
yval
Out[59]:
array([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[1, 0, 0, ..., 0, 0, 0]])
and predicted results look like this和预测结果看起来像这样
y_pred
Out[60]:
array([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]])
I want to find the TP, TN, FP, and FP我想找到 TP、TN、FP 和 FP
I tried this我试过这个
cm=confusion_matrix(yval, y_pred)
which gave this error这给了这个错误
ValueError: multilabel-indicator is not supported
tried this试过这个
cm=confusion_matrix(yval.argmax(axis=1), y_pred.argmax(axis=1))
TN = cm[0][0]
FN = cm[1][0]
TP = cm[1][1]
FP = cm[0][1]
gave zeros for all values TN=0, FN=0, TP=0 and FP=0
为所有值
TN=0, FN=0, TP=0 and FP=0
how can I get these values for a predicted array?如何获得预测数组的这些值?
You can use from sklearn.metrics import multilabel_confusion_matrix
to import multilabel confusion matrix.您可以使用
from sklearn.metrics import multilabel_confusion_matrix
来导入多from sklearn.metrics import multilabel_confusion_matrix
混淆矩阵。 After that the drill is:之后的练习是:
cm = multilabel_confusion_matrix(yval, y_pred)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.