Q:

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

A:

You assigned confusion_matrix to something (a list). So confusion_matrix does not refer to the Sklearn function anymore, but to a list. So you can't "call" it. What gave it away is this line: confusion_matrix.append(mat). 
You can solve this problem if you change the name of your list and restart your program.

