python中的混淆矩阵

2024-10-01 05:01:39 发布

您现在位置:Python中文网/ 问答频道 /正文

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

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

enter image description here

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


Tags: testrightlabelsnamespltaxclassset