1 function plot_basisgen_results(fns, params)
2 %
function plot_basisgen_results(fns[, params])
4 %
function plotting of basis generation results generated
5 % by basisgen_main. Fns is a cell array with names of the
6 % basisgen-files assumed to exist in $(RBMATLABTEMP)/basisgen
7 % Some fields in params can be used to select the produced plots.
8 % by
default all plots are generated
10 % required fields of params:
11 % plot_train_times: flag indicating, whether the train times are
13 % plot_train_estimators: flag indicating, whether the train
14 % error estimators are to be compared
15 % plot_test_estimators: flag indicating, whether the test
16 % error estimators are to be compared
17 % plot_test_errors: flag indicating, whether the test
18 % error estimators are to be compared
19 % plot_legends : cell array of legends to be used
20 % plot_linestyles : cell array of linestyles to be used
21 % plot_linecolors : cell array of linecolors
22 % plot_linewidths : vector of linewidths
24 % Bernard Haasdonk 7.6.2007
30 if ~isfield(params,
'plot_train_times')
31 params.plot_train_times = 1;
34 if ~isfield(params,
'plot_train_estimators')
35 params.plot_train_estimators = 1;
38 if ~isfield(params,'plot_test_estimators')
39 params.plot_test_estimators = 1;
42 if ~isfield(params,'plot_test_errors')
43 params.plot_test_errors = 1;
46 if ~isfield(params,'fontsize')
50 if ~isfield(params,'plot_legends_location')
51 legends_location = 'NorthEast';
53 legends_location = params.plot_legends_location;
56 %fns = {
'RB_random_fixed_50_tested',...
57 %
'RB_random_fixed_100_tested',...
58 %
'RB_uniform_fixed_49_tested',...
59 %
'RB_uniform_fixed_100_tested',...
60 %
'RB_uniform_refined_3_3_tested',...
61 %
'RB_adaptive_refined_3_3_tested'};
62 %fns = {
'RB_random_fixed_100_tested',...
63 %
'RB_uniform_fixed_100_tested',...
64 %
'RB_uniform_refined_3_3_tested',...
65 %
'RB_adaptive_refined_3_3_tested'};
66 %fns = {
'RB_uniform_fixed_100_tested',...
67 %
'RB_uniform_refined_3_3_tested',...
68 %
'RB_adaptive_refined_3_3_tested'};
69 %fns = {
'RB_uniform_fixed_100',...
70 %
'RB_adaptive_refined_2_2'};
72 %fns= {
'RB_uniform_fixed_16_tested', ...
73 %
'RB_uniform_fixed_64_tested', ...
74 %
'RB_uniform_fixed_256_tested', ...
75 %
'RB_uniform_fixed_1024_tested'};
79 'RB_random_fixed_16_tested', ...
80 'RB_random_fixed_64_tested', ...
81 'RB_random_fixed_256_tested', ...
82 'RB_random_fixed_1024_tested'};
84 %fns = {
'RB_adaptive_refined_2_2_r1_tested', ...
85 %
'RB_adaptive_refined_2_2_r2_tested', ...
86 %
'RB_adaptive_refined_2_2_r5_tested', ...
87 %
'RB_adaptive_refined_2_2_r10_tested'};
89 %fns = {
'RB_uniform_fixed_49',...
90 %
'RB_uniform_fixed_longt_49'};
91 %compute_RB_methods = {
'RB_random_fixed_100'};
93 %fns = {
'RB_adaptive_refined_tested',...
94 %
'RB_uniform_fixed_tested',
'RB_uniform_refined_tested'};
97 for fnum = 1:length(fns);
98 data{fnum} = load(fullfile(getenv(
'PDEMATLABTEMP'),
'basisgen',fns{fnum}));
103 % plot_legends : cell array of legends to be used
104 % plot_linestyles : cell array of linestyles to be used
105 % plot_linecolors : cell array of linecolors
106 % plot_linewidths : vector of linewidths
108 if ~isfield(params,
'plot_legends');
109 % generate legends (without
final '_tested'):
111 for fnum = 1:length(fns);
114 for j = length(i):-1:1
115 fn = [fn(1:(i(j)-1)),
'\_',fn(i(j)+1:end)];
117 i = findstr(fn,
'\_tested');
124 lfns = params.plot_legends;
128 if params.plot_train_times
130 % plot of computation times
132 for fnum = 1:length(fns);
133 l = length(data{fnum}.detailed_data.RB_info.toc_value_sequence);
135 times = [times;data{fnum}.detailed_data.RB_info.toc_value_sequence, ...
136 NaN * ones(1,size(times,2)-l)];
138 times = [times, NaN * ones(size(times,1),l-size(times,2));...
139 data{fnum}.detailed_data.RB_info.toc_value_sequence];
145 if isfield(params,'plot_linecolors
')
146 set(p(i),'color
',params.plot_linecolors{i});
148 if isfield(params,'plot_linewidths
')
149 set(p(i),'Linewidth
',params.plot_linewidths(i));
151 if isfield(params,'plot_linestyles
')
152 set(p(i),'Linestyle
',params.plot_linestyles{i});
156 title('computation time
')
157 xlabel('num basis functions N
');
158 ylabel('computation time [s]
')
159 legend(lfns,'location
',legends_location);
162 if params.plot_train_estimators
163 % plot of train-indicator decrease
165 for fnum = 1:length(fns);
166 l = length(data{fnum}.detailed_data.RB_info.max_err_sequence);
167 if size(estimators,2)> l
168 estimators = [estimators;data{fnum}.detailed_data.RB_info.max_err_sequence, ...
169 NaN * ones(1,size(estimators,2)-l)];
171 estimators = [estimators, NaN * ones(size(estimators,1),...
172 l-size(estimators,2));...
173 data{fnum}.detailed_data.RB_info.max_err_sequence];
176 figure, p = plot(estimators');
178 if isfield(params,'plot_linecolors')
179 set(p(i),'color',params.plot_linecolors{i});
181 if isfield(params,
'plot_linewidths')
182 set(p(i),'Linewidth',params.plot_linewidths(i));
184 if isfield(params,'plot_linestyles')
185 set(p(i),'Linestyle',params.plot_linestyles{i});
190 title(
'train error-indicator value decrease')
191 xlabel('num basis functions N');
192 ylabel('maximum indicator values')
193 set(gca,'Yscale','log');
194 legend(lfns,'location',legends_location);
197 max_test_error_available = zeros(length(fns));
198 max_test_estimator_available = zeros(length(fns));
199 min_test_estimator_available = zeros(length(fns));
200 min_test_error_available = zeros(length(fns));
201 for fnum = 1:length(fns);
202 if isfield(data{fnum}.detailed_data.RB_info, ...
203 'max_test_error_sequence')
204 max_test_error_available(fnum) = 1;
206 if isfield(data{fnum}.detailed_data.RB_info, ...
207 'max_test_estimator_sequence')
208 max_test_estimator_available(fnum) = 1;
210 if isfield(data{fnum}.detailed_data.RB_info, ...
211 'min_test_estimator_sequence')
212 min_test_estimator_available(fnum) = 1;
214 if isfield(data{fnum}.detailed_data.RB_info, ...
215 'min_test_error_sequence')
216 min_test_error_available(fnum) = 1;
220 %--------------------------------------------------------------------------
222 % plot of max test-estimator decrease
223 if params.plot_test_estimators
227 fi = find(max_test_estimator_available);
228 for fnum = 1:length(fi);
229 max_seq = data{fi(fnum)}.detailed_data.RB_info.max_test_estimator_sequence;
230 % l = length(max_seq);
231 %
if size(estimators,2)> l
235 % NaN * ones(1,size(estimators,2)-l)];
237 % estimators = [estimators, ...
238 % NaN * ones(size(estimators,1),...
239 % l-size(estimators,2));...
243 max_seqX = find(~isnan(max_seq));
244 max_seqY = max_seq(max_seqX);
245 l = length(max_seqX);
246 if size(estimatorsX,2)> l
250 NaN * ones(1,size(estimatorsX,2)-l)];
254 NaN * ones(1,size(estimatorsY,2)-l)];
256 estimatorsX = [estimatorsX, ...
257 NaN * ones(size(estimatorsX,1),...
258 l-size(estimatorsX,2));...
260 estimatorsY = [estimatorsY, ...
261 NaN * ones(size(estimatorsY,1),...
262 l-size(estimatorsY,2));...
269 % if isempty(isnan(estimators))
270 % p = plot(estimators');
272 % p = plot(estimators','x');
274 p = plot(estimatorsX',estimatorsY','x');
276 if isfield(params,'plot_linecolors')
277 set(p(i),'color',params.plot_linecolors{fi(i)});
279 if isfield(params,
'plot_linewidths')
280 set(p(i),'Linewidth',params.plot_linewidths(fi(i)));
282 if isfield(params,'plot_linestyles')
283 set(p(i),'Linestyle',params.plot_linestyles{fi(i)});
287 title(
'test estimator values decrease',
'Fontsize',params.fontsize)
288 xlabel('num basis functions N','Fontsize',params.fontsize);
289 ylabel('maximum test estimator values Delta_N','Fontsize',params.fontsize)
290 set(gca,'Yscale','log');
291 legend(lfns(fi),'location',legends_location,'Fontsize',params.fontsize);
296 % plot of min test-estimator decrease
297 if params.plot_test_estimators
299 fi = find(min_test_estimator_available);
300 for fnum = 1:length(fi);
301 l = length(data{fi(fnum)}.detailed_data.RB_info.min_test_estimator_sequence);
302 if size(estimators,2)> l
305 data{fi(fnum)}.detailed_data.RB_info.min_test_estimator_sequence(:)
', ...
306 NaN * ones(1,size(estimators,2)-l)];
308 estimators = [estimators, ...
309 NaN * ones(size(estimators,1),...
310 l-size(estimators,2));...
311 data{fi(fnum)}.detailed_data.RB_info.min_test_estimator_sequence(:)'];
316 if isempty(isnan(estimators))
317 p = plot(estimators');
319 p = plot(estimators','x');
322 if isfield(params,'plot_linecolors')
323 set(p(i),'color',params.plot_linecolors{fi(i)});
325 if isfield(params,
'plot_linewidths')
326 set(p(i),'Linewidth',params.plot_linewidths(fi(i)));
328 if isfield(params,'plot_linestyles')
329 set(p(i),'Linestyle',params.plot_linestyles{fi(i)});
332 title(
'test estimator values decrease')
333 xlabel('num basis functions N');
334 ylabel('minimum test estimator values Delta_N')
335 set(gca,'Yscale','log');
336 legend(lfns(fi),'location',legends_location);
341 % plot of max/min test-estimator ratio
342 if params.plot_test_estimators
348 for fnum = 1:length(fi);
349 max_seq = data{fi(fnum)}.detailed_data.RB_info.max_test_estimator_sequence;
350 min_seq = data{fi(fnum)}.detailed_data.RB_info.min_test_estimator_sequence;
351 seqX = find(~isnan(max_seq));
352 seqY = max_seq(seqX)./min_seq(seqX);
354 if size(estimatorsX,2)> l
358 NaN * ones(1,size(estimatorsX,2)-l)];
362 NaN * ones(1,size(estimatorsY,2)-l)];
364 estimatorsX = [estimatorsX, ...
365 NaN * ones(size(estimatorsX,1),...
366 l-size(estimatorsX,2));...
368 estimatorsY = [estimatorsY, ...
369 NaN * ones(size(estimatorsY,1),...
370 l-size(estimatorsY,2));...
377 % if isempty(isnan(estimators))
378 % p = plot(estimators');
380 % p = plot(estimators','x');
383 p = plot(estimatorsX',estimatorsY','x');
386 if isfield(params,'plot_linecolors')
387 set(p(i),'color',params.plot_linecolors{fi(i)});
389 if isfield(params,
'plot_linewidths')
390 set(p(i),'Linewidth',params.plot_linewidths(fi(i)));
392 if isfield(params,'plot_linestyles')
393 set(p(i),'Linestyle',params.plot_linestyles{fi(i)});
396 title(
'max/min test estimator ratio',
'Fontsize',params.fontsize)
397 xlabel('num basis functions N','Fontsize',params.fontsize);
398 ylabel('max/min test estimator ratio','Fontsize',params.fontsize)
399 set(gca,'Yscale','log');
400 legend(lfns(fi),'location',legends_location,'Fontsize',params.fontsize);
405 if isfield(params,'plot_max_test_vs_time')
407 % plot of max test-estimator versus training time
412 for fnum = 1:length(fi);
413 max_seq = data{fi(fnum)}.detailed_data.RB_info.max_test_estimator_sequence;
414 seqN = find(~isnan(max_seq));
415 seqX = data{fi(fnum)}.detailed_data.RB_info.toc_value_sequence(seqN);
416 seqY = max_seq(seqN);
418 if size(estimatorsX,2)> l
422 NaN * ones(1,size(estimatorsX,2)-l)];
426 NaN * ones(1,size(estimatorsY,2)-l)];
428 estimatorsX = [estimatorsX, ...
429 NaN * ones(size(estimatorsX,1),...
430 l-size(estimatorsX,2));...
432 estimatorsY = [estimatorsY, ...
433 NaN * ones(size(estimatorsY,1),...
434 l-size(estimatorsY,2));...
441 % if isempty(isnan(estimators))
442 % p = plot(estimators');
444 % p = plot(estimators','x');
447 p = plot(estimatorsX',estimatorsY','x');
450 if isfield(params,'plot_linecolors')
451 set(p(i),'color',params.plot_linecolors{fi(i)});
453 if isfield(params,
'plot_linewidths')
454 set(p(i),'Linewidth',params.plot_linewidths(fi(i)));
456 if isfield(params,'plot_linestyles')
457 set(p(i),'Linestyle',params.plot_linestyles{fi(i)});
460 title(
'max test estimator over training time',
'Fontsize',params.fontsize)
461 xlabel('training time','Fontsize',params.fontsize);
462 ylabel('max test estimator value','Fontsize',params.fontsize)
463 set(gca,'Yscale','log');
464 legend(lfns(fi),'location',legends_location,'Fontsize',params.fontsize);
468 % plot of max test-error decrease
469 if params.plot_test_errors
471 fi = find(max_test_error_available);
472 for fnum = 1:length(fi);
473 l = length(data{fi(fnum)}.detailed_data.RB_info.max_test_error_sequence);
474 if size(estimators,2)> l
475 estimators = [estimators;...
476 data{fi(fnum)}.detailed_data.RB_info.max_test_error_sequence(:)
',...
477 NaN * ones(1,size(estimators,2)-l)];
480 [estimators, NaN * ones(size(estimators,1),l-size(estimators,2));...
481 data{fi(fnum)}.detailed_data.RB_info.max_test_error_sequence(:)'];
486 if isempty(isnan(estimators))
487 p = plot(estimators');
489 p = plot(estimators','x');
492 if isfield(params,'plot_linecolors')
493 set(p(i),'color',params.plot_linecolors{fi(i)});
495 if isfield(params,
'plot_linewidths')
496 set(p(i),'Linewidth',params.plot_linewidths(fi(i)));
498 if isfield(params,'plot_linestyles')
499 set(p(i),'Linestyle',params.plot_linestyles{fi(i)});
502 title(
'test error values decrease')
503 xlabel('num basis functions N');
504 ylabel('maximum test error values')
505 set(gca,'Yscale','log');
506 legend(lfns(fi),'location',legends_location);
512 % plot of min test-error decrease
513 if params.plot_test_errors
515 fi = find(min_test_error_available);
516 for fnum = 1:length(fi);
517 l = length(data{fi(fnum)}.detailed_data.RB_info.min_test_error_sequence);
518 if size(estimators,2)> l
519 estimators = [estimators;...
520 data{fi(fnum)}.detailed_data.RB_info.min_test_error_sequence(:)
',...
521 NaN * ones(1,size(estimators,2)-l)];
524 [estimators, NaN * ones(size(estimators,1),l-size(estimators,2));...
525 data{fi(fnum)}.detailed_data.RB_info.min_test_error_sequence(:)'];
530 if isempty(isnan(estimators))
531 p = plot(estimators');
533 p = plot(estimators','x');
536 if isfield(params,'plot_linecolors')
537 set(p(i),'color',params.plot_linecolors{fi(i)});
539 if isfield(params,
'plot_linewidths')
540 set(p(i),'Linewidth',params.plot_linewidths(fi(i)));
542 if isfield(params,'plot_linestyles')
543 set(p(i),'Linestyle',params.plot_linestyles{fi(i)});
546 title(
'test error values decrease')
547 xlabel('num basis functions N');
548 ylabel('minimum test error values')
549 set(gca,'Yscale','log');
550 legend(lfns(fi),'location',legends_location);
559 % TO BE ADJUSTED TO NEW SYNTAX