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