Browse code

starting som prediction fine-tuned class-performance visualisation

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@112 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on21/01/2009 16:34:25
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,70 @@
1
+function [cPCAarg, Pdata, Pproto] = som_projections(D,sM,bmus)
2
+
3
+% SOM_PROJECTIONS Makes different kinds of projections for the data and the prototypes.
4
+%
5
+% [cPCAarg, Pdata, Pproto] = som_projections(D,sM,[bmus])
6
+%
7
+%      sD      (struct) data struct
8
+%              (matrix) size dlen x dim
9
+%      sM      (struct) map struct
10
+%              (matrix) size munits x dim: prototype vectors
11
+%      [bmus]  (vector) BMU for each data vector (calculated if not specified)
12
+%
13
+%      cPCAarg (cell array) PCA arguments: {V, me, l} from pcaproj function
14
+%      Pdata   (matrix) size dlen x 7, consisting of 3 projection coordinates from PCA, 
15
+%                       1 residual from the rest of the PCA-projection coordinates, 
16
+%                       and 3 color components 
17
+%      Pproto  (matrix) size dlen x 7, consisting of 3 projection coordinates from PCA, 
18
+%                       1 residual from the rest of the PCA-projection coordinates, 
19
+%                       3 color components, and 3 projection coordinates from CCA
20
+%
21
+% See also  PCAPROJ, CCA, SAMMON, SOM_PROJECTIONS_PLOT, SOM_COLORING, SOM_COLORCODE, 
22
+%           SOM_CLUSTERCOLOR, SOM_KMEANCOLOR.
23
+
24
+if isstruct(D), 
25
+    cn = D.comp_names;
26
+    D = D.data; 
27
+end
28
+[dlen dim] = size(D);
29
+if nargin<3, bmus = som_bmus(sM,D); end
30
+
31
+% projection of data
32
+
33
+[P0,V,me,l] = pcaproj(D,dim);
34
+D1 = som_fillnans(D,sM); 
35
+P1 = pcaproj(D1,V,me); 
36
+Res4 = zeros(dlen,1); 
37
+if dim<=3, 
38
+    Res4 = zeros(dlen,1); 
39
+else
40
+    Res4 = sqrt(sum(P1(:,4:end).*P1(:,4:end),2));
41
+end
42
+P1 = P1(:,1:min(3,dim)); 
43
+if dim<3, P1 = [P1, zeros(dlen,3-dim)]; end
44
+
45
+% projection of codebook vectors
46
+
47
+P1_m = pcaproj(sM,V,me); 
48
+Res4_m = zeros(dlen,1); 
49
+if dim<=3, 
50
+    Res4_m = zeros(dlen,1); 
51
+else
52
+    Res4_m = sum(P1_m(:,4:end).*P1_m(:,4:end),2);
53
+end
54
+P1_m = P1_m(:,1:min(3,dim)); 
55
+if dim<3, P1_m = [P1_m, zeros(size(P1_m,1),3-dim)]; end
56
+
57
+P2_m = cca(sM,P1_m,20); 
58
+
59
+PCol_m = som_coloring(sM); 
60
+
61
+PCol = PCol_m(bmus,:); 
62
+
63
+% output
64
+
65
+cPCAarg = {V,me,l};
66
+Pdata = [P1, Res4, PCol]; 
67
+Pproto = [P1_m, Res4_m, PCol_m, P2_m]; 
68
+ 
69
+return;
70
+ 
0 71
\ No newline at end of file