Home > . > prt_plot_ROC.m

prt_plot_ROC

PURPOSE ^

FORMAT prt_plot_ROC(PRT, model, fold, axes_handle)

SYNOPSIS ^

function prt_plot_ROC(PRT, model, fold, axes_handle)

DESCRIPTION ^

 FORMAT prt_plot_ROC(PRT, model, fold, axes_handle)

 This function plots the ROC plot 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_ROC(PRT, model, fold, axes_handle)
0002 % FORMAT prt_plot_ROC(PRT, model, fold, axes_handle)
0003 %
0004 % This function plots the ROC plot 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_ROC.m 706 2013-06-07 14:33:34Z cphillip $
0019 
0020 
0021 nfold = length(PRT.model(model).output.fold);
0022 
0023 if fold == 1
0024     fVals   = [];
0025     targets = [];
0026     
0027     for f = 1:nfold,
0028         targets = [targets;PRT.model(model).output.fold(f).targets];
0029         if isfield(PRT.model(model).output.fold(f),'func_val')
0030             fVvals_exist = 1;
0031             fVals  = [fVals;PRT.model(model).output.fold(f).func_val];
0032         else
0033             fVvals_exist = 0;
0034             fVals  = [fVals;...
0035                 PRT.model(model).output.fold(f).predictions];
0036         end
0037     end
0038     targpos = targets == 1; 
0039     
0040 else
0041     % if folds wise
0042     targets = PRT.model(model).output.fold(fold-1).targets;
0043         targpos = targets == 1;
0044     if isfield(PRT.model(model).output.fold(fold-1),'func_val')
0045         fVals  = PRT.model(model).output.fold(fold-1).func_val;
0046         fVvals_exist = 1;
0047     else
0048         fVvals_exist = 0;
0049         fVals  = PRT.model(model).output.fold(fold-1).predictions;
0050     end
0051 end
0052 
0053 
0054 
0055 %If no axes_handle is given, create a new window
0056 if ~exist('axes_handle', 'var')
0057     figure;
0058     axes_handle = axes;
0059 else
0060     set(axes_handle, 'XScale','linear');
0061 end
0062 
0063 
0064 rotate3d off
0065 cla(axes_handle, 'reset');
0066 [y,idx] = sort(fVals);
0067 targpos = targpos(idx);
0068 
0069 fp      = cumsum(single(targpos))/sum(single(targpos));
0070 tp      = cumsum(single(~targpos))/sum(single(~targpos));
0071 
0072 tp      = [0 ; tp ; 1];
0073 fp      = [0 ; fp ; 1];
0074 
0075 n       = size(tp, 1);
0076 A       = sum((fp(2:n) - fp(1:n-1)).*(tp(2:n)+tp(1:n-1)))/2;
0077 %
0078 %                 axis xy
0079 plot(axes_handle,fp,tp,'--ks','LineWidth',1, 'MarkerEdgeColor','k',...
0080     'MarkerFaceColor','k',...
0081     'MarkerSize',2);
0082 title(axes_handle,sprintf('Receiver Operator Curve / Area Under Curve = %3.2f',A));
0083 xlabel(axes_handle,'False positives','FontWeight','bold')
0084 ylabel(axes_handle,'True positives','FontWeight','bold')
0085 set(axes_handle,'Color',[1,1,1])
0086

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