python confusion matrix template

from sklearn.metrics import confusion_matrix
y_true = ["cat", "ant", "cat", "cat", "ant", "bird"]
y_pred = ["ant", "ant", "cat", "cat", "ant", "cat"]
print(confusion_matrix(y_true, y_pred, labels=[ "cat","ant", "bird"]))
y_true1 = [0, 1, 0, 0, 1, 2]
y_pred1 = [1, 1, 0, 0, 1, 0]
print(confusion_matrix(y_true1, y_pred1, labels=[0,1,2]))

 

 

 

Published 234 original articles · won praise 61 · views 120 000 +

Guess you like

Origin blog.csdn.net/weixin_42528089/article/details/104888751