Mercurial > hg > camir-aes2014
comparison core/tools/machine_learning/display_mahalanobis_metric.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function display_mahalanobis_metric(A, labels) | |
2 % display a mala matrix and its stats | |
3 | |
4 if nargin < 2 | |
5 labels = num2cell(1:size(A,1)); | |
6 | |
7 elseif ~iscell(labels) | |
8 | |
9 features = labels; | |
10 labels = features.labels; | |
11 end | |
12 | |
13 | |
14 | |
15 figure; | |
16 | |
17 % plot matrix | |
18 imagesc(A); | |
19 axis xy; | |
20 | |
21 % set labels | |
22 set(gca,'YTick', 1:numel(labels), ... | |
23 'YTickLabel', labels); | |
24 set(gca,'XTick',1:numel(labels), ... | |
25 'XTickLabel', labels); | |
26 | |
27 % --- | |
28 % approximate parameter weights: | |
29 % diagonal and sum(abs(row)) | |
30 % TODO: make nshow dependend on percentile | |
31 % --- | |
32 | |
33 nshow = min(numel(labels), 50); | |
34 figure; | |
35 | |
36 % get diagonal values of the Matrix | |
37 diagw = abs(diag(A)); | |
38 | |
39 % --- | |
40 % weight with feature values if possible | |
41 % --- | |
42 if exist('features','var') | |
43 | |
44 diagw = diagw.* mean(features.vector(),2); | |
45 end | |
46 | |
47 | |
48 [diagw, idx] = sort(diagw, 'descend'); | |
49 | |
50 % normalise | |
51 alld = sum(diagw); | |
52 | |
53 % plot | |
54 bar(diagw(1:nshow)./ alld); | |
55 set(gca,'XTick',1:nshow, ... | |
56 'XTickLabel', labels(idx(1:nshow))); | |
57 | |
58 ylabel ('relevance factor'); | |
59 | |
60 if exist('features','var') | |
61 xlabel 'normalised weight' | |
62 else | |
63 xlabel 'matrix factors' | |
64 end | |
65 | |
66 end |