简体   繁体   English

在Matlab中以图形方式绘制混淆矩阵

[英]graphically plot confusion matrix in matlab

I have a confusion matrix like this: 我有一个这样的混乱矩阵:

[1   0   0   0   0 ]
[0  0.9  0  0.1  0 ]
[0   0   1   0   0 ]
[0   0   0   1   0 ]
[0.1 0  0.2  0  0.7]

where rows represent ground of truth, columns represent classification result. 其中行表示事实依据,列表示分类结果。 I would like to plot it graphically in a grid. 我想以图形方式将其绘制在网格中。 I tried surface but it only shows a 4x4 figure whilst my matrix has 5x5 size. 我尝试了surface但是它只显示4x4的图形,而我的矩阵只有5x5的尺寸。 how can i do that? 我怎样才能做到这一点?

You want your confusion values to define cell values instead of node values (as surface does). 您希望混淆值定义单元格值而不是节点值(就像surface一样)。

You can use imshow for your purpose, maybe combined with some colormap . 您可以根据需要使用imshow ,也可以结合使用一些colormap

A = [1   0   0   0   0 
     0  0.9  0  0.1  0 
     0   0   1   0   0 
     0   0   0   1   0 
     0.1 0  0.2  0  0.7 ]


imshow(A, 'InitialMagnification',10000)  % # you want your cells to be larger than single pixels
colormap(jet) % # to change the default grayscale colormap 

在此处输入图片说明

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

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