comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/som_dreval.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 [sig,cm,truex,truey] = som_dreval(sR,D,sigmea,inds1,inds2,andor)
2
3 % SOM_DREVAL Evaluate the significance of the given descriptive rule.
4 %
5 % [sig,Cm,truex,truey] = som_dreval(cR,D,sigmea,[inds1],[inds2],[andor])
6 %
7 % sR (struct) a rule struct, or an array of rule structs
8 % D (matrix) the data, of size [dlen x nr]
9 % sigmea (string) significance measure ('accuracy','accuracyI','mutuconf'),
10 % see definitions below
11 % [inds1] (vector) indeces belonging to the group
12 % (by default: the whole data set)
13 % [inds2] (vector) indeces belonging to the contrast group
14 % (by default: the rest of the data set)
15 % [andor] (string) 'and' or 'or': which conjunction operator to use
16 % to join the rules for each variable
17 %
18 % sig (scalar) significance of the rule
19 % cm (vector) length 4, vectorized confusion matrix ([a,c,b,d]: see below)
20 % truex (vector) binary vector indicating for each item in the
21 % group whether it was true or not
22 % truey (vector) binary vector indicating for each item in the
23 % contrast group whether it was true or not
24 %
25 % Descriptive rule significance is measured as the match between the
26 % given groups (inds1 = G1, inds2 = G2) and the rule being true or false.
27 %
28 % G1 G2
29 % --------------- accuracy = (a+d) / (a+b+c+d)
30 % true | a | b |
31 % |-------------- mutuconf = a*a / ((a+b)(a+c))
32 % false | c | d |
33 % --------------- accuracyI = a / (a+b+c)
34 %
35 % See also SOM_DRSIGNIF, SOM_DRMAKE.
36
37 % Contributed to SOM Toolbox 2.0, March 4th, 2002 by Juha Vesanto
38 % Copyright (c) by Juha Vesanto
39 % http://www.cis.hut.fi/projects/somtoolbox/
40
41 % Version 2.0beta juuso 040302
42
43 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44
45 % input arguments
46 if isstruct(D),
47 switch D.type,
48 case 'som_data', D = D.data;
49 case 'som_map', D = D.codebook;
50 end
51 end
52 [dlen,dim] = size(D);
53 if nargin<4, inds1 = 1:dlen; end
54 if nargin<5, i = ones(dlen,1); i(inds1) = 0; inds2 = find(i); end
55 if nargin<6, andor = 'and'; end
56
57 % initialize
58 nr = length(sR);
59 X = D(inds1,:);
60 Y = D(inds2,:);
61 nx = size(X,1);
62 ny = size(Y,1);
63 truex = ones(nx,1);
64 truey = ones(ny,1);
65
66 % go through the individual rules
67 for i=1:nr,
68 tx = (X(:,i)>=sR(i).low & X(:,i)<sR(i).high);
69 tx(isnan(X(:,i))) = sR(i).nanis;
70
71 ty = (Y(:,i)>=sR(i).low & Y(:,i)<sR(i).high);
72 ty(isnan(Y(:,i))) = sR(i).nanis;
73
74 switch andor,
75 case 'and', truex = (truex & tx); truey = (truey & ty);
76 case 'or', truex = (truex | tx); truey = (truey | ty);
77 end
78 end
79
80 % evaluate criteria
81 tix = sum(truex(isfinite(truex)));
82 tiy = sum(truey(isfinite(truey)));
83 cm = [tix,nx-tix,tiy,ny-tiy];
84 sig = som_drsignif(sigmea,cm);
85
86 return;
87
88