view Code/Classifiers/processKMeansResults.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 [ groupStats, orderedGroups ] = processKMeansResults( ID, idx, ...
    groupingCriteria, masterFileOutputID, titleName, DEBUG )
    
    if( length( idx ) ~= length( groupingCriteria ) )
        disp('EEEK!');
        pause;
    end

    groupIDs = '';
    groupStr = '';
    for( i = 1 : length( idx ))
%         fprintf( fileOutputID, '%s \t %d \n', groupingCriteria(i), idx(i) );
        gID = [ groupingCriteria(i) num2str( idx(i) )];
        groupIDs = [ groupIDs ; gID ];
        groupStr = [ groupStr gID ];
    end

    % ------------- work out the confusion matrix -------------------------

    groups = unique( groupIDs, 'rows' );
    noOfGroups = length( groups );
    orderedGroups = sort(cellstr(groups));
    groupStats = [];
    for( i = 1 : noOfGroups )
        groupStats(i) = ((length( strfind( groupStr, char(orderedGroups(i)))))/length( idx ) ) * 100;
    end
    
    if(DEBUG == 1)
        figure(1);
        bar( groupStats );
        set( gca, 'XTickLabel', orderedGroups );
        title([ titleName ' ' ID]);
    end
end