【问题标题】:Is it possible to subplot confusion matrices?是否可以绘制混淆矩阵?
【发布时间】:2017-10-17 18:10:38
【问题描述】:

我正在使用plot_confusion() 函数绘制几个混淆矩阵,我想将它们放在一个子图中(2x5 数字),但它似乎不起作用。它分别显示每个混淆矩阵。绘制混乱是否有任何限制?谢谢!

figure

Subplot(2,1,1);

plotconfusion(targets,outputs,'train');

subplot(2,1,2);

plotconfusion(targets1,outputs1,'test')

【问题讨论】:

    标签: matlab plot machine-learning deep-learning matlab-figure


    【解决方案1】:

    您“不应该”这样做(不包括该功能),但您可以稍微欺骗一下 Matlab,因为在一天结束时它只是一个轴对象:

    %% First Example Data
    [x,t] = cancer_dataset;
    net = patternnet(10);
    net = train(net,x,t);
    y = net(x);
    
    %// plot
    plotconfusion(t,y)
    
    %// get handle and enable second plöt
    cp1 = gcf;
    cp1.NextPlot = 'new'
    ax1 = findobj(cp1,'Type','Axes')
    
    %% Second Example Data
    [x,t] = cancer_dataset;
    net = patternnet(5);
    net = train(net,2*x,t);
    y = net(x);
    
    %// plot
    plotconfusion(t,y)
    
    %// get handle and enable third plöt
    cp2 = gcf;
    cp2.NextPlot = 'new'
    ax2 = findobj(cp2,'Type','Axes')
    
    %% combine plots
    
    f1 = figure(42)
    f1s1 = subplot(121)
    copyobj(allchild(ax1),f1s1)
    f1s2 = subplot(122)
    copyobj(allchild(ax2),f1s2)
    

    您松开了标签和标题,可能需要调整轴,但我想您可以做到。

    【讨论】:

    • 出于好奇,您为什么“不应该这样做”?
    • @AnderBiguri 这更具隐喻性,因为工具箱会确保您完全无法控制句柄。默认情况下,它甚至不允许您打开多个图形窗口。它不应该是您可以进一步使用的普通图形或轴对象,例如子图。
    • @thewaywalk。非常感谢您的英勇努力。在上面的混淆矩阵中,灰色框显示了准确率和召回率的百分比。那么我们可以为每个班级绘制一个准确率与召回率的数字吗?
    猜你喜欢
    • 2016-01-31
    • 1970-01-01
    • 2020-10-20
    • 2013-10-25
    • 2016-06-04
    • 2021-10-01
    • 2020-07-15
    • 2019-12-26
    相关资源
    最近更新 更多