[英]About confusion_matrix() in sklearn
print(type(prediction))
print(type(np.array(testset_target)))
mat = confusion_matrix(np.array(testset_target),prediction)
output:输出:
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-15-ebab29cbd03f> in <module>
23 print(type(prediction))
24 print(type(np.array(testset_target)))
---> 25 mat = confusion_matrix(np.array(testset_target),prediction)
26 confusion_matrix.append(mat)
27 acc_sco=accuracy_score(prediction,testset_target)
TypeError: 'list' object is not callable
They are both np.ndarray type, but why error said list都是np.ndarray类型,但是为什么报错说list
You assigned confusion_matrix
to something (a list).您将
confusion_matrix
分配给了某物(列表)。 So confusion_matrix
does not refer to the Sklearn function anymore, but to a list.所以
confusion_matrix
不再引用 Sklearn 函数,而是引用一个列表。 So you can't "call" it.所以你不能“调用”它。 What gave it away is this line:
confusion_matrix.append(mat)
.泄露的是这一行:
confusion_matrix.append(mat)
。
You can solve this problem if you change the name of your list and restart your program.如果更改列表名称并重新启动程序,则可以解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.