python中的混淆矩阵

python中的混淆矩阵,python,matplotlib,scikit-learn,Python,Matplotlib,Scikit Learn,我试图用python创建一个混淆矩阵。但是,正如您在下图中看到的,我的类标签彼此不匹配。我基本上希望y轴以T恤/上衣开始,以踝靴结束。这是我的代码: 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

我试图用python创建一个混淆矩阵。但是,正如您在下图中看到的,我的类标签彼此不匹配。我基本上希望y轴以T恤/上衣开始,以踝靴结束。这是我的代码:

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

我是python新手,所以我不确定我做错了什么。

在最后两行之前执行此操作:

class_names = class_names[::-1]

看起来反转列表就是你所需要的吗?

你试过反转y轴吗?试着用旋转=180替换旋转=360我已经对旋转进行了调整,它只是改变了文本标签的方向。在第一行plt.setp修复后,进行此操作,谢谢!!