wolffd@0: function [out, stats, features, individual] = test_generic_display_results(file, get_features, show) wolffd@0: % [out, stats] = test_generic_display_results([file], get_features) wolffd@0: % wolffd@0: % [out, stats, features, individual] = test_generic_display_results([file], get_features) wolffd@0: % wolffd@0: % displays the finalresults mat file and enables wolffd@0: % further analysis and duiagnostics of the individual runs wolffd@0: wolffd@0: features = []; wolffd@0: wolffd@0: if nargin < 3 wolffd@0: show = 1; wolffd@0: end wolffd@0: if nargin < 2 wolffd@0: get_features = 1; wolffd@0: end wolffd@0: wolffd@0: global comparison; wolffd@0: global comparison_ids; wolffd@0: wolffd@0: if nargin < 1 || isempty(file) || isnumeric(file) 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: if exist('file','var') && isnumeric(file) wolffd@0: file = u{idx(file)}; wolffd@0: else wolffd@0: if numel(idx) > 1 wolffd@0: file = u{idx(ask_dataset())}; wolffd@0: else wolffd@0: file = u{idx(1)}; wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: wolffd@0: % --- wolffd@0: % LOAD THE RESULT DATA wolffd@0: % We have: wolffd@0: % Y wolffd@0: % out.fparams wolffd@0: % trainparams wolffd@0: % dataPartition wolffd@0: % mean_ok_test wolffd@0: % var_ok_test wolffd@0: % mean_ok_train wolffd@0: % --- wolffd@0: load(file); wolffd@0: wolffd@0: % compability wolffd@0: if isfield(out, 'mlrparams') wolffd@0: for i = 1:numel(out) wolffd@0: out(i).trainparams = out(i).mlrparams; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: wolffd@0: % --- wolffd@0: % % get statistics for feature parameters wolffd@0: % Visualise the accuracy and variance wolffd@0: % --- wolffd@0: if isfield(out, 'inctrain') && show wolffd@0: for i = 1:numel(out) wolffd@0: wolffd@0: figure; wolffd@0: boxplot([out(i).inctrain.mean_ok_test], sqrt([out(i).inctrain.var_ok_test]), [out(i).inctrain.mean_ok_train]); wolffd@0: set(gca,'XTick',1:numel(out(i).inctrain.trainfrac), ... wolffd@0: 'XTickLabel', out(i).inctrain.trainfrac* 100); wolffd@0: wolffd@0: xlabel ('fraction of training data'); wolffd@0: title (sprintf('increasing training size test, config %d',i)); wolffd@0: legend('train', 'train weighted', 'test', 'test weighted'); wolffd@0: wolffd@0: end wolffd@0: end wolffd@0: 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: % --- 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: % --- wolffd@0: % display parameter statistics wolffd@0: % --- wolffd@0: stats = test_generic_display_param_influence(out, show); wolffd@0: wolffd@0: wolffd@0: if nargout < 3 wolffd@0: return; wolffd@0: end wolffd@0: % --- wolffd@0: % display statistics and get features wolffd@0: % for run with best test success wolffd@0: % --- wolffd@0: [resfile, featfile] = get_res_filename(out, idx); wolffd@0: wolffd@0: % --- wolffd@0: % import features: wolffd@0: % 1. reset databse wolffd@0: % 2. import features wolffd@0: % 3. assign to clip ids as in ranking wolffd@0: % --- wolffd@0: if get_features wolffd@0: type = MTTAudioFeatureDBgen.import_type(featfile); wolffd@0: db_name = MTTAudioFeatureDBgen.db_name(type); wolffd@0: eval(sprintf('global %s', db_name)); wolffd@0: eval(sprintf('%s.reset();', db_name)); wolffd@0: eval(sprintf('features = %s.import(featfile);', db_name)); wolffd@0: wolffd@0: if isfield(out,'clip_ids') wolffd@0: clips = MTTClip(out(1).clip_ids); wolffd@0: features = clips.features(type); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % Display Metric Stats wolffd@0: % tmp = test_mlr_display_metric_stats(individual.out, individual.diag, features); wolffd@0: % --- wolffd@0: wolffd@0: if nargout < 4 wolffd@0: return; wolffd@0: end wolffd@0: individual = load(resfile); wolffd@0: for i = 1:numel(out) wolffd@0: wolffd@0: [resfile, featfile] = get_res_filename(out, i); wolffd@0: wolffd@0: if get_features wolffd@0: % reset db and load testing features wolffd@0: eval(sprintf('global %s', db_name)); wolffd@0: eval(sprintf('%s.reset();', db_name)); wolffd@0: eval(sprintf('%s.import(featfile);', db_name)); wolffd@0: end wolffd@0: wolffd@0: % load individual results wolffd@0: if i == 1; wolffd@0: wolffd@0: individual = load(resfile); wolffd@0: else wolffd@0: wolffd@0: individual(i) = load(resfile); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: function out = ask_dataset() wolffd@0: % --- wolffd@0: % displays the parameters of the datasets, wolffd@0: % and asks for the right one to display wolffd@0: % --- wolffd@0: clc; wolffd@0: u = dir(); wolffd@0: u = {u.name}; wolffd@0: [idx, strpos] = substrcellfind(u, '_params.mat', 1); wolffd@0: wolffd@0: for i = 1:numel(idx) wolffd@0: file = u{idx(i)}; wolffd@0: fprintf('------------ Dataset nr. %d --------------\n',i); wolffd@0: fprintf('Filename: %s\n',file); wolffd@0: type(file); wolffd@0: end wolffd@0: wolffd@0: out = (input('Please choose the dataset number: ')); wolffd@0: end wolffd@0: wolffd@0: wolffd@0: function [resfile, featfile] = get_res_filename(out, i) wolffd@0: % get filename given test results and index wolffd@0: wolffd@0: paramhash = hash(xml_format(out(i).fparams),'MD5'); wolffd@0: wolffd@0: paramhash_mlr = hash(xml_format(out(i).trainparams),'MD5'); wolffd@0: wolffd@0: featfile = sprintf('runlog_%s_feat.mat', paramhash); wolffd@0: wolffd@0: resfile = sprintf('runlog_%s.%s_results.mat',... wolffd@0: paramhash, paramhash_mlr); wolffd@0: end 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