简体   繁体   English

Python中的混淆矩阵

[英]Confusion matrix in python

I am trying to create a confusion matrix in python. 我正在尝试在python中创建混淆矩阵。 However as you can see in the image below, my class labels arent matching up with each other. 但是,如您在下图中所看到的,我的班级标签arent彼此匹配。 I essentially want the y axis to start with Tshirt/Top and end with Ankle Boots . 我本质上希望y轴以Tshirt / Top开始并以Ankle Boots结尾。 This is my code: 这是我的代码:

test_labels = test_labels.argmax(axis=1)
predictions = predictions.argmax(axis=1)
cm = confusion_matrix(test_labels, predictions)

plt.setp(ax.xaxis.set_ticklabels(class_names), rotation=90, horizontalalignment='right')
plt.setp(ax.yaxis.set_ticklabels(class_names), rotation=360, horizontalalignment='right')

在此处输入图片说明

I am new to python so im not sure what I am doing wrong. 我是python的新手,所以我不确定自己在做什么错。

Do this before last 2 lines: 在最后两行之前执行此操作:

class_names = class_names[::-1]

Looks like a reversed list is all you need? 看起来您需要的只是一个反向列表?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM