annotate toolboxes/MIRtoolbox1.3.2/somtoolbox/som_drsignif.m @ 0:e9a9cd732c1e tip

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