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,63 @@
1
+function sig = som_drsignif(sigmea,Cm)
2
+
3
+% SOM_DRSIGNIF Significance measure from confusion matrix between two clusters and a rule.
4
+%
5
+% sig = som_drsignif(sigmea,Cm)
6
+% 
7
+%  sigmea   (string) significance measure: 'accuracy', 
8
+%                    'mutuconf' (default), or 'accuracyI'.
9
+%                    (See definitions below).
10
+%  Cn                Vectorized confusion matrix, or a matrix of such vectors.
11
+%           (vector) [a, c, b, d] (see below)
12
+%           (matrix) [[a1,c1,b1,d1], ..., [an,cn,bn,dn]]
13
+%
14
+%  sig      (vector) length=n, significance values 
15
+%
16
+% The confusion matrix Cm below between group (G) and contrast group (not G)
17
+% and rule (true - false) is used to determine the significance values:
18
+%
19
+%          G    not G    
20
+%       ---------------    accuracy  = (a+d) / (a+b+c+d)
21
+% true  |  a  |   b   |    
22
+%       |--------------    mutuconf  =  a*a  / ((a+b)(a+c)) 
23
+% false |  c  |   d   | 
24
+%       ---------------    accuracyI =   a   / (a+b+c)
25
+%
26
+% See also  SOM_DREVAL, SOM_DRMAKE.
27
+
28
+% Contributed to SOM Toolbox 2.0, March 4th, 2002 by Juha Vesanto
29
+% Copyright (c) by Juha Vesanto
30
+% http://www.cis.hut.fi/projects/somtoolbox/
31
+
32
+% Version 2.0beta juuso 040302
33
+
34
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
+%% input arguments
36
+
37
+true_x     = Cm(:,1); % x     = in group
38
+false_x    = Cm(:,2); % false = rule is false
39
+true_y     = Cm(:,3); % true  = rule is true
40
+false_y    = Cm(:,4); % y     = not in group
41
+
42
+true_items = true_x + true_y; 
43
+x_items    = true_x + false_x; 
44
+all_items  = true_x + false_x + true_y + false_y; 
45
+true_or_x  = x_items + true_items - true_x; 
46
+
47
+switch sigmea, 
48
+case 'mutuconf',
49
+    % mutual confidence, or relevance (as defined in WSOM2001 paper)
50
+    sig = zeros(size(true_x)); 
51
+    i = find(true_items>0 & x_items>0); 
52
+    sig(i) = (true_x(i).^2) ./ (true_items(i).*x_items(i)); 
53
+case 'accuracy', 
54
+    % accuracy 
55
+    sig = (true_x + false_y) ./ all_items;
56
+case 'accuracyI', 
57
+    % accuracy such that false_y is left out of consideration
58
+    sig = true_x./true_or_x;
59
+otherwise, 
60
+    error(['Unrecognized significance measures: ' sigmea]);
61
+end 
62
+
63
+return;