wolffd@0: function [sig,cm,truex,truey] = som_dreval(sR,D,sigmea,inds1,inds2,andor) wolffd@0: wolffd@0: % SOM_DREVAL Evaluate the significance of the given descriptive rule. wolffd@0: % wolffd@0: % [sig,Cm,truex,truey] = som_dreval(cR,D,sigmea,[inds1],[inds2],[andor]) wolffd@0: % wolffd@0: % sR (struct) a rule struct, or an array of rule structs wolffd@0: % D (matrix) the data, of size [dlen x nr] wolffd@0: % sigmea (string) significance measure ('accuracy','accuracyI','mutuconf'), wolffd@0: % see definitions below wolffd@0: % [inds1] (vector) indeces belonging to the group wolffd@0: % (by default: the whole data set) wolffd@0: % [inds2] (vector) indeces belonging to the contrast group wolffd@0: % (by default: the rest of the data set) wolffd@0: % [andor] (string) 'and' or 'or': which conjunction operator to use wolffd@0: % to join the rules for each variable wolffd@0: % wolffd@0: % sig (scalar) significance of the rule wolffd@0: % cm (vector) length 4, vectorized confusion matrix ([a,c,b,d]: see below) wolffd@0: % truex (vector) binary vector indicating for each item in the wolffd@0: % group whether it was true or not wolffd@0: % truey (vector) binary vector indicating for each item in the wolffd@0: % contrast group whether it was true or not wolffd@0: % wolffd@0: % Descriptive rule significance is measured as the match between the wolffd@0: % given groups (inds1 = G1, inds2 = G2) and the rule being true or false. wolffd@0: % wolffd@0: % G1 G2 wolffd@0: % --------------- accuracy = (a+d) / (a+b+c+d) wolffd@0: % true | a | b | wolffd@0: % |-------------- mutuconf = a*a / ((a+b)(a+c)) wolffd@0: % false | c | d | wolffd@0: % --------------- accuracyI = a / (a+b+c) wolffd@0: % wolffd@0: % See also SOM_DRSIGNIF, SOM_DRMAKE. wolffd@0: wolffd@0: % Contributed to SOM Toolbox 2.0, March 4th, 2002 by Juha Vesanto wolffd@0: % Copyright (c) by Juha Vesanto wolffd@0: % http://www.cis.hut.fi/projects/somtoolbox/ wolffd@0: wolffd@0: % Version 2.0beta juuso 040302 wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: % input arguments wolffd@0: if isstruct(D), wolffd@0: switch D.type, wolffd@0: case 'som_data', D = D.data; wolffd@0: case 'som_map', D = D.codebook; wolffd@0: end wolffd@0: end wolffd@0: [dlen,dim] = size(D); wolffd@0: if nargin<4, inds1 = 1:dlen; end wolffd@0: if nargin<5, i = ones(dlen,1); i(inds1) = 0; inds2 = find(i); end wolffd@0: if nargin<6, andor = 'and'; end wolffd@0: wolffd@0: % initialize wolffd@0: nr = length(sR); wolffd@0: X = D(inds1,:); wolffd@0: Y = D(inds2,:); wolffd@0: nx = size(X,1); wolffd@0: ny = size(Y,1); wolffd@0: truex = ones(nx,1); wolffd@0: truey = ones(ny,1); wolffd@0: wolffd@0: % go through the individual rules wolffd@0: for i=1:nr, wolffd@0: tx = (X(:,i)>=sR(i).low & X(:,i)=sR(i).low & Y(:,i)