0001 function prt_plot_prediction(PRT, model, fold, marker_size, axes_handle)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 nfold = length(PRT.model(model).output.fold);
0024 bcl = 0;
0025
0026
0027 fVals = [];
0028 targets = [];
0029
0030 for f = 1:nfold,
0031 targets = [targets;PRT.model(model).output.fold(f).targets];
0032 if isfield(PRT.model(model).output.fold(f),'func_val')
0033 fVvals_exist = 1;
0034 fVals = [fVals;PRT.model(model).output.fold(f).func_val];
0035 else
0036 fVvals_exist = 0;
0037 fVals = [fVals;...
0038 PRT.model(model).output.fold(f).predictions];
0039 end
0040 end
0041 tarmax = max(targets);
0042 if fold==1
0043 targpos = targets == 1;
0044 if length(find(targpos))~=length(targets) && ~isempty(find(targpos))
0045
0046 bcl = 1;
0047 end
0048 end
0049
0050 if fold>1
0051
0052 targets = PRT.model(model).output.fold(fold-1).targets;
0053 targpos = targets == tarmax;
0054 if isfield(PRT.model(model).output.fold(fold-1),'func_val')
0055 fVals = PRT.model(model).output.fold(fold-1).func_val;
0056 fVvals_exist = 1;
0057 else
0058 fVvals_exist = 0;
0059 fVals = PRT.model(model).output.fold(fold-1).predictions;
0060 end
0061 end
0062
0063
0064
0065 if ~exist('marker_size', 'var')
0066 marker_size = 7;
0067 end
0068
0069 if ~exist('axes_handle', 'var')
0070 figure;
0071 axes_handle = axes;
0072 else
0073 set(axes_handle, 'XScale','linear');
0074 end
0075
0076 cla(axes_handle, 'reset');
0077 rotate3d off
0078 colorbar('peer',axes_handle,'off')
0079 set(axes_handle,'Color',[1,1,1])
0080
0081 if fVvals_exist
0082 if fold == 1
0083 foldlabels = 1:nfold;
0084 for f = 2:nfold+1
0085 targets = PRT.model(model).output.fold(f-1).targets;
0086 targpos = targets == tarmax;
0087 fVals = PRT.model(model).output.fold(f-1).func_val;
0088 func_valsc1 = fVals(targpos);
0089 func_valsc2 = fVals(~targpos);
0090 yc1 = (f-1)*ones(length(func_valsc1),1);
0091 yc2 = (f-1)*ones(length(func_valsc2),1);
0092 if f==2
0093 maxfv = max(abs([func_valsc1;func_valsc2]));
0094 else
0095 maxtmp = max(abs([func_valsc1;func_valsc2]));
0096 if maxfv < maxtmp, maxfv = maxtmp; end
0097 end
0098 pl1 = plot(axes_handle,func_valsc1,yc1,'kx','MarkerSize',marker_size);
0099 hold(axes_handle,'on');
0100 if ~isempty(yc1), isyc1 = 1; plot1 = pl1; else isyc1 = 0; end
0101 pl2 = plot(axes_handle,func_valsc2,yc2,'ro','MarkerSize',marker_size);
0102 hold(axes_handle,'on');
0103 if ~isempty(yc2), isyc2 = 1; plot2 = pl2; else isyc2 = 0; end
0104 end
0105 else
0106 foldlabels = fold-1;
0107 func_valsc1 = fVals(targpos);
0108 func_valsc2 = fVals(~targpos);
0109 yc1 = (fold-1)*ones(length(func_valsc1),1);
0110 yc2 = (fold-1)*ones(length(func_valsc2),1);
0111 maxfv = max(abs([func_valsc1;func_valsc2]));
0112 pl1 = plot(axes_handle,func_valsc1,yc1,'kx','MarkerSize',marker_size);
0113 hold(axes_handle,'on');
0114 if ~isempty(yc1), isyc1 = 1; plot1 = pl1; else isyc1 = 0; end
0115 pl2 = plot(axes_handle,func_valsc2,yc2,'ro','MarkerSize',marker_size);
0116 hold(axes_handle,'on');
0117 if ~isempty(yc2), isyc2 = 1; plot2 = pl2; else isyc2 = 0; end
0118 end
0119
0120
0121 y = [0:nfold+1]';
0122 if strcmp(PRT.model(model).input.machine.function,'prt_machine_gpml');
0123 x = 0.5*ones(nfold+2,1);
0124 plot(axes_handle,x,y,'--','Color',[1 1 1]*.6);
0125 xlim(axes_handle,[0 1]);
0126 elseif strcmp(PRT.model(model).input.machine.function,'prt_machine_RT_bin')
0127
0128 else
0129 x = zeros(nfold+2,1);
0130 plot(axes_handle,x,y,'--','Color',[1 1 1]*.6);
0131 xlim(axes_handle,[-maxfv-0.5 maxfv+0.5]);
0132 end
0133 ylim(axes_handle,[0 nfold+1.3]);
0134 xlabel(axes_handle,'function value','FontWeight','bold');
0135 h=ylabel(axes_handle,'fold','FontWeight','bold');
0136 set(h,'Rotation',90)
0137
0138
0139
0140 classNames{1} = PRT.model(model).input.class(2).class_name;
0141 classNames{2} = PRT.model(model).input.class(1).class_name;
0142
0143
0144 if (isyc1 && isyc2) || bcl
0145 legend([plot1,plot2],classNames,'Color',[1,1,1]);
0146 else
0147 if isyc1
0148 legend(plot1,classNames{1});
0149 else
0150 legend(plot2,classNames{2});
0151 end
0152 end
0153 set(axes_handle,'YTick',foldlabels)
0154 hold(axes_handle,'off');
0155 set(axes_handle,'Color',[1,1,1],'Visible','on')
0156
0157
0158 title(axes_handle,'')
0159 else
0160 set(axes_handle,'Color',[1,1,1])
0161 beep
0162 disp('No function values to display!')
0163 end