Mercurial > hg > emotion-detection-top-level
view Code/Classifiers/getConfusionMatrix.m @ 4:92ca03a8fa99 tip
Update to ICASSP 2013 benchmark
author | Dawn Black |
---|---|
date | Wed, 13 Feb 2013 11:02:39 +0000 |
parents | |
children |
line wrap: on
line source
function [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames,... masterFileOutputID, distanceMeasure ) groupNames = char(groupNames); % for emotion detection give the confusion matrix as % ----------------------------------------------------------------- % positive correctly identified | positive incorrectly identified (1,2) % negative incorrectly identified (2,1) | negative correctly identified % ------------------------------------------------------------------ % which group has the most samples? [maxValue, maxIndex] = max( groupStats ); maxGroup = groupNames( maxIndex,: ); % if we are performing emotion detection if( ~isempty(strfind( groupNames(1,:), 'N' )) ... || ~isempty(strfind( groupNames(1,:), 'P' ))) confusionMatrix = zeros(2,2); % check groups for any missing if( length(groupStats) < 4 ) % find the missing group if( groupFind( groupNames, 'N1' ) == 0 ) % missing N1 groupNames = [groupNames; 'N1']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'N2' ) == 0 ) % missing N2 groupNames = [groupNames; 'N2']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'P1' ) == 0 ) % missing P1 groupNames = [groupNames; 'P1']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'P2' ) == 0 ) %missing P2 groupNames = [groupNames; 'P2']; groupStats = [groupStats 0]; end end % let the group with the maximum success (either 1 or 2) be the % cluster for that emotion if( strfind( maxGroup, 'N' )) % negative samples were detected most reliably confusionMatrix(2,2) = maxValue; if( strfind( maxGroup, '1' )) % group 1 is the negative group % find the number of positive samples incorrectly identified idx = groupFind( groupNames, 'P1' ); confusionMatrix(1,2) = groupStats( idx ); % group 2 is the positive group % find the number of positive samples correctly identified idx = groupFind( groupNames, 'P2' ); confusionMatrix(1,1) = groupStats( idx ); % find the number of negative samples incorrectly identified idx = groupFind( groupNames, 'N2' ); confusionMatrix(2,1) = groupStats( idx ); else % group 2 is the negative group % find the number of positive samples incorrectly identified idx = groupFind( groupNames, 'P2' ); confusionMatrix(1,2) = groupStats( idx ); % group 1 is the positive group % find the number of positive samples correctly identified idx = groupFind( groupNames, 'P1' ); confusionMatrix(1,1) = groupStats( idx ); % find the number of negative samples incorrectly identified idx = groupFind( groupNames, 'N1' ); confusionMatrix(2,1) = groupStats( idx ); end else % positive samples were detected most reliably confusionMatrix(1,1) = maxValue; if( strfind( maxGroup, '1' )) % group 1 is the positive group % find the number of positive samples incorrectly identified idx = groupFind( groupNames, 'P2' ); confusionMatrix(1,2) = groupStats( idx ); % group 2 is the negative group % find the number of negative samples correctly identified idx = groupFind( groupNames, 'N2' ); confusionMatrix(2,2) = groupStats( idx ); % find the number of negative samples incorrectly identified idx = groupFind( groupNames, 'N1' ); confusionMatrix(2,1) = groupStats( idx ); else % group 2 is the positive group % find the number of positive samples incorrectly identified idx = groupFind( groupNames, 'P1' ); confusionMatrix(1,2) = groupStats( idx ); % group 1 is the negative group % find the number of negative samples correctly identified idx = groupFind( groupNames, 'N1' ); confusionMatrix(2,2) = groupStats( idx ); % find the number of negative samples incorrectly identified idx = groupFind( groupNames, 'N2' ); confusionMatrix(2,1) = groupStats( idx ); end end confusionMatrix(3,3) = confusionMatrix(1,1) + confusionMatrix(2,2); disp(distanceMeasure); % print latex results to the screen str1 = sprintf(' & %2.2f & %2.2f & \\\\', confusionMatrix(1,1), confusionMatrix(1,2) ); disp(str1); str1 = sprintf(' & %2.2f & %2.2f & \\\\', confusionMatrix(2,1), confusionMatrix(2,2) ); disp(str1); str1 = sprintf(' & & & %2.2f \\\\',confusionMatrix(3,3) ); disp(str1); disp(' '); fprintf( masterFileOutputID, '\n %f \t %f \n %f \t %f \n %f \t %f \t %f \n', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(2,1), confusionMatrix(2,2), 0, 0, confusionMatrix(3,3)); end % for gender detection give the confusion matrix as % -------------------------------------------------------------------- % male correctly identified as male | male incorrectly identified as female | male incorrectly identified as trans % female incorrectly identified as male | female correctly identified | female incorrectly identified as trans % trans incorrectly identified as male | trans incorrectly identified as female | trans correctly identified % -------------------------------------------------------------------- % if we are performing gender detection if( ~isempty(strfind( groupNames(1,:), 'F' )) ... || ~isempty(strfind( groupNames(1,:), 'M' ))... || ~isempty(strfind( groupNames(1,:), 'T' ))) confusionMatrix = zeros(3,3); % check groups for any missing if( length(groupStats) < 9 ) % find the missing group if( groupFind( groupNames, 'M1' ) == 0 ) groupNames = [groupNames; 'M1']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'M2' ) == 0 ) groupNames = [groupNames; 'M2']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'M3' ) == 0 ) groupNames = [groupNames; 'M3']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'F1' ) == 0 ) groupNames = [groupNames; 'F1']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'F2' ) == 0 ) groupNames = [groupNames; 'F2']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'F3' ) == 0 ) groupNames = [groupNames; 'F3']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'T1' ) == 0 ) groupNames = [groupNames; 'T1']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'T2' ) == 0 ) groupNames = [groupNames; 'T2']; groupStats = [groupStats 0]; end if( groupFind( groupNames, 'T3' ) == 0 ) groupNames = [groupNames; 'T3']; groupStats = [groupStats 0]; end end % let the group with the maximum success (either 1, 2 or 3) be the % cluster for that gender if( strfind( maxGroup, 'M' )) % male samples were detected most reliably confusionMatrix(1,1) = maxValue; if( strfind( maxGroup, '1' )) % group 1 is the male group % find the female group (F2 or F3, can't be F1) idx1 = groupFind( groupNames, 'F2' ); idx2 = groupFind( groupNames, 'F3' ); if( groupStats( idx1 ) > groupStats( idx2 ) ) % group 1 is the male group % female is group 2 and trans group 3 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,3) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,2) = groupStats( idx ); else % female is group 3 and trans is group 2 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,3) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,2) = groupStats( idx ); end elseif( strfind( maxGroup, '2' )) % group 2 is the male group % find the female group (F1 or F3, can't be F2) idx1 = groupFind( groupNames, 'F1' ); idx2 = groupFind( groupNames, 'F3' ); if( groupStats( idx1 ) > groupStats( idx2 ) ) % female is group 1 and trans group 3 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,3) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,2) = groupStats( idx ); else % female is group 3 and trans is group 1 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,3) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'F2' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'F3' ); confusionMatrix(3,2) = groupStats( idx ); end else % group 3 is the male group % find the female group (F1 or F2, can't be F3) idx1 = groupFind( groupNames, 'F1' ); idx2 = groupFind( groupNames, 'F2' ); if( groupStats( idx1 ) > groupStats( idx2 ) ) % female is group 1 and trans group 2 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,3) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'F3' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'F1' ); confusionMatrix(3,2) = groupStats( idx ); else % female is group 2 and trans is group 1 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,3) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'F3' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'F2' ); confusionMatrix(3,2) = groupStats( idx ); end end % -------------------------------------------------------------------- % male correctly identified as male (1,1) | male incorrectly identified as female (1,2) | male incorrectly identified as trans % female incorrectly identified as male (2,1) | female correctly identified (2,2) | female incorrectly identified as trans % trans incorrectly identified as male (3,1) | trans incorrectly identified as female (3,2) | trans correctly identified (3,3) % -------------------------------------------------------------------- elseif( strfind( maxGroup, 'F' )) % female samples were detected most reliably confusionMatrix(2,2) = maxValue; if( strfind( maxGroup, '1' )) % group 1 is the female group % find the male group (F2 or F3, can't be F1) idx1 = groupFind( groupNames, 'M2' ); idx2 = groupFind( groupNames, 'M3' ); if( groupStats( idx1 ) > groupStats( idx2 ) ) % male is group 2 and trans group 3 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,1) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,2) = groupStats( idx ); else % female is group 1 % male is group 3 and trans is group 2 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,1) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,2) = groupStats( idx ); end elseif( strfind( maxGroup, '2' )) % group 2 is the female group % find the male group (M1 or M3, can't be M2) idx1 = groupFind( groupNames, 'M1' ); idx2 = groupFind( groupNames, 'M3' ); if( groupStats( idx1 ) > groupStats( idx2 ) ) % male is group 1 and trans group 3 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,1) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,2) = groupStats( idx ); else % group 2 is the female group % male is group 3 and trans is group 1 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,1) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,2) = groupStats( idx ); end else % group 3 is the female group % find the male group (M1 or M2, can't be M3) idx1 = groupFind( groupNames, 'M1' ); idx2 = groupFind( groupNames, 'M2' ); if( groupStats( idx1 ) > groupStats( idx2 ) ) % male is group 1 and trans group 2 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,1) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,2) = groupStats( idx ); else % female is group 3 % male is group 2 and trans is group 1 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,1) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,3) = groupStats( idx ); % trans correctly identified as trans idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,2) = groupStats( idx ); end end % -------------------------------------------------------------------- % male correctly identified as male (1,1) | male incorrectly identified as female (1,2) | male incorrectly identified as trans % female incorrectly identified as male (2,1) | female correctly identified (2,2) | female incorrectly identified as trans % trans incorrectly identified as male (3,1) | trans incorrectly identified as female (3,2) | trans correctly identified (3,3) % -------------------------------------------------------------------- elseif( strfind( maxGroup, 'T' )) % trans samples were detected most reliably confusionMatrix(3,3) = maxValue; if( strfind( maxGroup, '1' )) % group 1 is the trans group % find the female group (F2 or F3, can't be F1) idx1 = groupFind( groupNames, 'F2' ); idx2 = groupFind( groupNames, 'F3' ); if( groupStats( idx1 ) > groupStats( idx2 ) ) % female is group 2 and male group 3 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,1) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F1' ); confusionMatrix(1,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,2) = groupStats( idx ); else % female is group 3 and male is group 2 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,1) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F1' ); confusionMatrix(1,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,2) = groupStats( idx ); end elseif( strfind( maxGroup, '2' )) % group 2 is the trans group % find the female group (F1 or F3, can't be F2) idx1 = groupFind( groupNames, 'F1' ); idx2 = groupFind( groupNames, 'F3' ); if( groupStats( idx1 ) > groupStats( idx2 ) ) % female is group 1 and male group 3 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,1) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F2' ); confusionMatrix(1,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,2) = groupStats( idx ); else % group 2 is the trans group % female is group 3 and male is group 1 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,1) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F3' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F2' ); confusionMatrix(1,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T3' ); confusionMatrix(3,2) = groupStats( idx ); end else % group 3 is the trans group % find the female group (F1 or F2, can't be F3) idx1 = groupFind( groupNames, 'F1' ); idx2 = groupFind( groupNames, 'F2' ); if( groupStats( idx1 ) > groupStats( idx2 ) ) % female is group 1 and male group 2 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,1) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F3' ); confusionMatrix(1,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,2) = groupStats( idx ); else % group 3 is the trans group % female is group 2 and male is group 1 % find the number of male samples incorrectly identified as female idx = groupFind( groupNames, 'M2' ); confusionMatrix(1,2) = groupStats( idx ); % find the number of male samples incorrectly identified as trans idx = groupFind( groupNames, 'M3' ); confusionMatrix(1,3) = groupStats( idx ); % male correctly identified as male idx = groupFind( groupNames, 'M1' ); confusionMatrix(1,1) = groupStats( idx ); % female correctly identified as female idx = groupFind( groupNames, 'F2' ); confusionMatrix(2,2) = groupStats( idx ); % female incorrectly identified as male idx = groupFind( groupNames, 'F1' ); confusionMatrix(2,1) = groupStats( idx ); % female incorrectly identified as trans idx = groupFind( groupNames, 'F3' ); confusionMatrix(1,3) = groupStats( idx ); % trans incorrectly identified as male idx = groupFind( groupNames, 'T1' ); confusionMatrix(3,1) = groupStats( idx ); % trans incorrectly identified as female idx = groupFind( groupNames, 'T2' ); confusionMatrix(3,2) = groupStats( idx ); end end end confusionMatrix(4,4) = confusionMatrix(1,1) + confusionMatrix(2,2) + confusionMatrix(3,3); disp(distanceMeasure); % print latex results to the screen str1 = sprintf(' & %2.2f & %2.2f & %2.2f & \\\\', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(1,3) ); disp(str1); str1 = sprintf(' & %2.2f & %2.2f & %2.2f & \\\\', confusionMatrix(2,1), confusionMatrix(2,2), confusionMatrix(2,3) ); disp(str1); str1 = sprintf(' & & & & %2.2f \\\\',confusionMatrix(4,4) ); disp(str1); disp(' '); fprintf( masterFileOutputID, '\n %f \t %f \t %f \n %f \t %f \t %f \n %f \t %f \t %f \n %f \t %f \t %f \t %f \n', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(1,3), confusionMatrix(2,1), confusionMatrix(2,2), confusionMatrix(2,3), confusionMatrix(3,1), confusionMatrix(3,2), confusionMatrix(3,3), 0, 0, 0, confusionMatrix(4,4)); end end function [idx] = groupFind( groupNames, str ) idx = 0; for( i=1: length( groupNames ) ) if( ~isempty(strfind( groupNames(i,:), str(1) )) && ~isempty(strfind( groupNames(i,:), str(2) ))) idx = i; end end end