Home > . > prt_plot_confusion_matrix.m

prt_plot_confusion_matrix

PURPOSE ^

FORMAT prt_plot_confusion_matrix(PRT, model, fold, axes_handle)

SYNOPSIS ^

function prt_plot_confusion_matrix(PRT, model, fold, axes_handle)

DESCRIPTION ^

 FORMAT prt_plot_confusion_matrix(PRT, model, fold, axes_handle)

 This function plots the confusion matrix that appears on prt_ui_results
 Inputs:
       PRT             - data/design/model structure (it needs to contain
                         at least one estimated model).
       model           - the number of the model that will be ploted
       fold            - the number of the fold
       axes_handle     - (Optional) axes where the plot will be displayed

 Output:
       None
__________________________________________________________________________
 Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function prt_plot_confusion_matrix(PRT, model, fold, axes_handle)
0002 % FORMAT prt_plot_confusion_matrix(PRT, model, fold, axes_handle)
0003 %
0004 % This function plots the confusion matrix that appears on prt_ui_results
0005 % Inputs:
0006 %       PRT             - data/design/model structure (it needs to contain
0007 %                         at least one estimated model).
0008 %       model           - the number of the model that will be ploted
0009 %       fold            - the number of the fold
0010 %       axes_handle     - (Optional) axes where the plot will be displayed
0011 %
0012 % Output:
0013 %       None
0014 %__________________________________________________________________________
0015 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0016 
0017 % Written by M. J. Rosa
0018 % $Id: prt_plot_confusion_matrix.m 706 2013-06-07 14:33:34Z cphillip $
0019 
0020 %If no axes_handle is given, create a new window
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 % confusion matrix
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 % add values
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

Generated on Tue 10-Feb-2015 18:16:33 by m2html © 2005