二分类下的混淆矩阵

from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt

y_test = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
y_pred = [0, 1, 0, 0, 0, 0, 0, 1, 1, 1]
confusion_matrix = confusion_matrix(y_test, y_pred)
print(confusion_matrix)
plt.matshow(confusion_matrix)
plt.title('Confusion matrix')
plt.colorbar()
plt.ylabel('True label')
plt.xlabel('Predicted label')
plt.show()
[[4 1]
 [2 3]]


posted @ 2019-10-22 11:07  昕友软件开发  阅读(1649)  评论(0编辑  收藏  举报
欢迎访问我的开源项目:xyIM企业即时通讯