wolffd@0: function display_mahalanobis_metric(A, labels) wolffd@0: % display a mala matrix and its stats wolffd@0: wolffd@0: if nargin < 2 wolffd@0: labels = num2cell(1:size(A,1)); wolffd@0: wolffd@0: elseif ~iscell(labels) wolffd@0: wolffd@0: features = labels; wolffd@0: labels = features.labels; wolffd@0: end wolffd@0: wolffd@0: wolffd@0: wolffd@0: figure; wolffd@0: wolffd@0: % plot matrix wolffd@0: imagesc(A); wolffd@0: axis xy; wolffd@0: wolffd@0: % set labels wolffd@0: set(gca,'YTick', 1:numel(labels), ... wolffd@0: 'YTickLabel', labels); wolffd@0: set(gca,'XTick',1:numel(labels), ... wolffd@0: 'XTickLabel', labels); wolffd@0: wolffd@0: % --- wolffd@0: % approximate parameter weights: wolffd@0: % diagonal and sum(abs(row)) wolffd@0: % TODO: make nshow dependend on percentile wolffd@0: % --- wolffd@0: wolffd@0: nshow = min(numel(labels), 50); wolffd@0: figure; wolffd@0: wolffd@0: % get diagonal values of the Matrix wolffd@0: diagw = abs(diag(A)); wolffd@0: wolffd@0: % --- wolffd@0: % weight with feature values if possible wolffd@0: % --- wolffd@0: if exist('features','var') wolffd@0: wolffd@0: diagw = diagw.* mean(features.vector(),2); wolffd@0: end wolffd@0: wolffd@0: wolffd@0: [diagw, idx] = sort(diagw, 'descend'); wolffd@0: wolffd@0: % normalise wolffd@0: alld = sum(diagw); wolffd@0: wolffd@0: % plot wolffd@0: bar(diagw(1:nshow)./ alld); wolffd@0: set(gca,'XTick',1:nshow, ... wolffd@0: 'XTickLabel', labels(idx(1:nshow))); wolffd@0: wolffd@0: ylabel ('relevance factor'); wolffd@0: wolffd@0: if exist('features','var') wolffd@0: xlabel 'normalised weight' wolffd@0: else wolffd@0: xlabel 'matrix factors' wolffd@0: end wolffd@0: wolffd@0: end