Python 关于sklearn中的混淆矩阵()

Python 关于sklearn中的混淆矩阵(),python,numpy,Python,Numpy,输出: print(type(prediction)) print(type(np.array(testset_target))) mat = confusion_matrix(np.array(testset_target),prediction) --------------------------------------------------------------------------- TypeError回溯(最近一次调用上次) 在里面 23打印(类型(预测)) 24打印(类型

输出:

print(type(prediction))
print(type(np.array(testset_target)))
mat = confusion_matrix(np.array(testset_target),prediction)

---------------------------------------------------------------------------
TypeError回溯(最近一次调用上次)
在里面
23打印(类型(预测))
24打印(类型(np.array(testset_target)))
--->25 mat=混淆矩阵(np.数组(测试集目标),预测)
26矩阵附加(mat)
27 acc\u sco=准确度得分(预测、测试集\u目标)
TypeError:“列表”对象不可调用

它们都是np.ndarray类型,但为什么错误会说列表

您将
混淆矩阵
分配给某个东西(列表)。因此,
混淆矩阵
不再指Sklearn函数,而是指一个列表。所以你不能“叫”它。给出它的是这一行:
混乱\u matrix.append(mat)


如果您更改列表的名称并重新启动程序,则可以解决此问题。

非常感谢。我没注意到。这真的很有帮助。非常感谢你!如果你的问题解决了,你可以考虑接受这个答案。这能回答你的问题吗?您之前是否将任何列表声明为混淆矩阵=[]?
<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