是否可以绘制包含 90 个类的混淆矩阵? [英] Is it possible to plot a confusion matrix with 90 classes?

查看:41
本文介绍了是否可以绘制包含 90 个类的混淆矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望为我的分类模型绘制混淆矩阵.它有大约 20000 个文档需要分类为 90 个类.我收到的混淆矩阵很大.我想绘制这个,但我似乎只能在任何地方找到二元分类图.是否可以绘制这个多类混淆矩阵?我尝试了一些方法,但它没有显示一个清晰的.

I wish to plot the confusion matrix for my classification model. It has about 20000 documents that need to be classified to 90 classes. The confusion matrix I receive is huge. I wish to plot this but I only seem to find binary classification plots everywhere. Is it possible to plot this multi-class confusion matrix? I tried some methods but it does't display a clear one.

这是我的混淆矩阵的样子:

This is how my confusion matrix looks like:

[[3919  344    0 ...,    0    0    1]
 [ 267 2739    0 ...,    0    0    0]
 [   1    6   17 ...,    0    0    0]
 ..., 
 [   4    1    0 ...,    6    0    0]
 [   0    2    0 ...,    0    0    0]
 [   6    1    0 ...,    0    0   15]]

推荐答案

这里是一些使用 matplotlib 的示例代码(添加网格并关闭插值)

Here is some sample code using matplotlib ( added grid and switching off the interpolation)

import numpy as np
import matplotlib.pyplot as plt

confmat=np.random.rand(90,90)
ticks=np.linspace(0, 89,num=90)
plt.imshow(confmat, interpolation='none')
plt.colorbar()
plt.xticks(ticks,fontsize=6)
plt.yticks(ticks,fontsize=6)
plt.grid(True)
plt.show()

这篇关于是否可以绘制包含 90 个类的混淆矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆