Mercurial > hg > camir-ismir2012
diff core/tools/machine_learning/display_mahalanobis_metric.m @ 0:cc4b1211e677 tip
initial commit to HG from
Changeset:
646 (e263d8a21543) added further path and more save "camirversion.m"
author | Daniel Wolff |
---|---|
date | Fri, 19 Aug 2016 13:07:06 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/tools/machine_learning/display_mahalanobis_metric.m Fri Aug 19 13:07:06 2016 +0200 @@ -0,0 +1,66 @@ +function display_mahalanobis_metric(A, labels) +% display a mala matrix and its stats + +if nargin < 2 + labels = num2cell(1:size(A,1)); + +elseif ~iscell(labels) + + features = labels; + labels = features.labels; +end + + + +figure; + +% plot matrix +imagesc(A); +axis xy; + +% set labels +set(gca,'YTick', 1:numel(labels), ... + 'YTickLabel', labels); +set(gca,'XTick',1:numel(labels), ... + 'XTickLabel', labels); + +% --- +% approximate parameter weights: +% diagonal and sum(abs(row)) +% TODO: make nshow dependend on percentile +% --- + +nshow = min(numel(labels), 50); +figure; + +% get diagonal values of the Matrix +diagw = abs(diag(A)); + +% --- +% weight with feature values if possible +% --- +if exist('features','var') + + diagw = diagw.* mean(features.vector(),2); +end + + +[diagw, idx] = sort(diagw, 'descend'); + +% normalise +alld = sum(diagw); + +% plot +bar(diagw(1:nshow)./ alld); +set(gca,'XTick',1:nshow, ... + 'XTickLabel', labels(idx(1:nshow))); + +ylabel ('relevance factor'); + +if exist('features','var') + xlabel 'normalised weight' +else + xlabel 'matrix factors' +end + +end \ No newline at end of file