python 混淆矩陣模板

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]))

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章