0001 function prt_plot_confusion_matrix(PRT, model, fold, axes_handle)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 if ~exist('axes_handle', 'var')
0022 figure;
0023 axes_handle = axes;
0024 else
0025 set(axes_handle, 'XScale','linear');
0026 end
0027
0028
0029
0030 cla(axes_handle, 'reset');
0031 if fold == 1
0032 mconmat(:,:) = PRT.model(model).output.stats.con_mat;
0033 else
0034 mconmat(:,:) = PRT.model(model).output.fold(fold-1).stats.con_mat;
0035 end
0036 myH=bar3(axes_handle,mconmat,'detached','w');
0037 nclass = size(mconmat,1);
0038 for j = 1:nclass,
0039 conLabels{j} = num2str(j);
0040 end
0041 rotate3d on
0042 if fold == 1
0043 title(axes_handle,sprintf('Confusion matrix: all folds'),'FontWeight','bold');
0044 else
0045 title(axes_handle,sprintf('Confusion matrix: fold %d',fold-1),'FontWeight','bold');
0046 end
0047 xlabel(axes_handle,'True','FontWeight','bold');
0048 ylabel(axes_handle,'Predicted','FontWeight','bold');
0049 set(axes_handle,'XTick',1:nclass);
0050 set(axes_handle,'XTickLabel',conLabels);
0051 set(axes_handle,'YTick',1:nclass);
0052 set(axes_handle,'YTickLabel',conLabels);
0053 grid(axes_handle,'on');
0054 set(axes_handle,'Color',[0.8 0.8 0.8]);
0055 axis square; axis vis3d; axis tight;
0056
0057 for foo_row=1:size(mconmat,1)
0058 for foo_col=1:size(mconmat,2)
0059 foo_zval=mconmat(foo_row,foo_col);
0060 if foo_row==foo_col, foo_color='g'; else foo_color='r';end
0061 text(foo_col,foo_row,foo_zval,num2str(foo_zval),...
0062 'Color',foo_color);
0063 end
0064 end