wolffd@0: function [out, stats] = write_mat_results_ISMIR13RBM_singletraining(dirin,fileout) wolffd@0: % combine the test results from the directories supplied, wolffd@0: % group them according to dataset parameter values wolffd@0: % combine the test results from the directories supplied, wolffd@0: % group them according to dataset parameter values wolffd@0: wolffd@0: features = []; wolffd@0: show = 1; wolffd@0: wolffd@0: if nargin == 0 wolffd@0: dirin{1} = './'; wolffd@0: end wolffd@0: wolffd@0: global comparison; wolffd@0: global comparison_ids; wolffd@0: wolffd@0: newout = []; wolffd@0: thisdir = pwd; wolffd@0: % loop through al lthe result directories and wolffd@0: for diri = 1:numel(dirin) wolffd@0: wolffd@0: % --- wolffd@0: % go to directory and locate file wolffd@0: % --- wolffd@0: cd(dirin{diri}); wolffd@0: wolffd@0: u = dir(); wolffd@0: u = {u.name}; wolffd@0: [idx, strpos] = substrcellfind(u, '_finalresults.mat', 1); wolffd@0: wolffd@0: if numel(idx) < 1 wolffd@0: error 'This directory contains no valid test data'; wolffd@0: end wolffd@0: wolffd@0: % just one or more tests in this folder? wolffd@0: if exist('file','var') && isnumeric(file) wolffd@0: cprint(1, 'loading one result file'); wolffd@0: file = u{idx(file)}; wolffd@0: data = load(file); wolffd@0: sappend(out,data.out); wolffd@0: else wolffd@0: for filei = 1:numel(idx) wolffd@0: cprint(1, 'loading result file %i of %i',filei, numel(idx)); wolffd@0: file = u{idx(filei)}; wolffd@0: data = load(file); wolffd@0: newout = sappend(newout,data.out); wolffd@0: end wolffd@0: end wolffd@0: % reset act directory wolffd@0: cd(thisdir); wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % filter according to training parameter C wolffd@0: % wolffd@0: % NOTE :if we don't filter by C, we get strong overfitting with training wolffd@0: % success > 96 % and test set performance aorund 65 % wolffd@0: % --- wolffd@0: cs = zeros(numel(newout),1); wolffd@0: for i=1:numel(newout) wolffd@0: cs(i) = newout(i).trainparams.C; wolffd@0: end wolffd@0: cvals = unique(cs); wolffd@0: wolffd@0: for ci=1:numel(cvals) wolffd@0: valididx = find(cs == cvals(ci)); wolffd@0: filteredout = newout(valididx); wolffd@0: wolffd@0: % --- wolffd@0: % get parameter statistics wolffd@0: % --- wolffd@0: stats = test_generic_display_param_influence(filteredout, show); wolffd@0: wolffd@0: % get maximal values for each test set bin wolffd@0: % --- wolffd@0: % trainparams.dataset contains sets which have each only one bin of the wolffd@0: % ismir testsets wolffd@0: % --- wolffd@0: max_idx = [stats.trainparams.dataset.mean_ok_train.max_idx]; wolffd@0: ok_test = zeros(2, numel(max_idx)); wolffd@0: ok_train = zeros(2, numel(max_idx)); wolffd@0: ok_config = []; wolffd@0: % cycle over all test sets and save best result wolffd@0: for i=1:numel(max_idx) wolffd@0: ok_test(:,i) = filteredout(max_idx(i)).mean_ok_test; wolffd@0: ok_train(:,i) = filteredout(max_idx(i)).mean_ok_train; wolffd@0: ok_config = sappend(ok_config,struct('trainparams',filteredout(max_idx(i)).trainparams, ... wolffd@0: 'fparams',filteredout(max_idx(i)).fparams)); wolffd@0: end wolffd@0: % save the stuff wolffd@0: out(ci).mean_ok_test = mean(ok_test,2); wolffd@0: out(ci).var_ok_test = var(ok_test,0,2); wolffd@0: out(ci).mean_ok_train = mean(ok_train,2); wolffd@0: out(ci).var_ok_train = var(ok_train,0,2); wolffd@0: out(ci).trainparams.C = cvals(ci); wolffd@0: out(ci).ok_config = ok_config; wolffd@0: out(ci).ok_test = ok_test; wolffd@0: out(ci).ok_train = ok_train; wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % show results for different C wolffd@0: % --- wolffd@0: if numel([out.mean_ok_test]) > 1 && show wolffd@0: wolffd@0: % plot means % plot std = sqrt(var) % plot training results wolffd@0: figure; wolffd@0: boxplot([out.mean_ok_test], sqrt([out.var_ok_test]), [out.mean_ok_train]); wolffd@0: title (sprintf('Performance for all configs')); wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % write max. test success wolffd@0: % --- wolffd@0: mean_ok_test = [out.mean_ok_test]; wolffd@0: [val, idx] = max(mean_ok_test(1,:)); wolffd@0: if show wolffd@0: fprintf(' --- Maximal test set success: nr. %d, %3.2f percent. --- \n', idx, val * 100) wolffd@0: end wolffd@0: wolffd@0: % save wolffd@0: save([hash(strcat(dirin{:}),'md5') '_summary'], 'out'); wolffd@0: wolffd@0: end wolffd@0: wolffd@0: wolffd@0: wolffd@0: function boxplot(mean, std, train); wolffd@0: wolffd@0: bar([train; mean]', 1.5); wolffd@0: hold on; wolffd@0: errorbar(1:size(mean,2), mean(1,:), std(1,:),'.'); wolffd@0: % plot(train,'rO'); wolffd@0: colormap(spring); wolffd@0: axis([0 size(mean,2)+1 max(0, min(min([train mean] - 0.1))) max(max([train mean] + 0.1))]); wolffd@0: end