Mercurial > hg > emotion-detection-top-level
view Code/Classifiers/kmeans_HNR_Singing.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 [] = kmeans_HNR_Singing( varargin ) cd 'C:\Users\dawn\Dropbox\TestResults' DEBUG = 1; % output results file name masterFileOutputID = fopen( 'kmeans_Singing_MedianHNR_male01.txt', 'a' ); % input results file name inputFileName = 'singingMedianHNRStats_male01.txt'; fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); inputFileID = fopen( inputFileName ); noOfArguments = length(varargin); outputFileName = 'individualResults/kmeans_Results_'; resultsFileName = 'kmeans_Results_'; titleName = ''; for i=1 : noOfArguments titleName = [ titleName varargin{i} '_']; fprintf( masterFileOutputID, '%s_', varargin{i} ); end outputFileName = [ outputFileName titleName ]; resultsFileName = [ resultsFileName titleName ]; fprintf( masterFileOutputID, '\t' ); outputFileName = [ outputFileName '.txt']; resultsFileName = [ resultsFileName '.txt']; fileOutputID = fopen( outputFileName, 'w' ); fileKMeansOutputID = fopen( resultsFileName, 'w' ); % -------------------- get the data from the results file --------------- lineCount = 0; fileCount = 0; data = []; while( ~(feof(inputFileID)) ) outputValues = []; thestr = fgetl(inputFileID); fileCount = fileCount + 1; % determine whether we have a positive or negative sample sampleEmotion( fileCount ) = 'U'; if( ~(isempty(strfind(thestr,'pos')))) % sample is positive sampleEmotion( fileCount ) = 'P'; elseif( ~(isempty(strfind(thestr,'neg')))) % sample is negative sampleEmotion( fileCount ) = 'N'; else disp('EEEK!'); pause; end % determine whether we have a male, female or trans sample gender( fileCount ) = '?'; if( ~(isempty(strfind(thestr,'fem')))) % gender is female gender( fileCount ) = 'F'; elseif( ~(isempty(strfind(thestr,'male')))) % gender is male gender( fileCount ) = 'M'; elseif( ~(isempty(strfind(thestr,'trans')))) % gender is trans gender( fileCount ) = 'T'; else disp('EEEK!'); pause; end %how many values are in the string? spaces = strfind( thestr, ' ' ); numberstr = thestr( spaces(1) : end ); % chop off the file name vars = sscanf( numberstr, '%f', inf ); data( fileCount, : ) = vars; lineCount = lineCount + 1; end fclose(inputFileID); % ------------ apply the k-means classifier ------------------------ noOfClusters = 2; % we are only trying to identify positive and negative emotions [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... 'start', 'sample', 'Distance', 'cityblock'); %display results grouped by emotion fprintf( masterFileOutputID, '\n Emotion grouping \n'); processKMeansResults( 'cityblock', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName, DEBUG ); if(DEBUG == 1) disp('press space'); pause; end [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... 'start', 'sample', 'Distance', 'sqEuclidean'); processKMeansResults( 'sqEuclidean', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName, DEBUG ); if(DEBUG == 1) disp('press space'); pause; end %display results grouped by gender fprintf( masterFileOutputID, '\n Gender grouping \n'); noOfClusters = 3; [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... 'start', 'sample', 'Distance', 'cityblock'); processKMeansResults( 'cityblock', idx, gender, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName, DEBUG ); if(DEBUG == 1) disp('press space'); pause; end [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... 'start', 'sample', 'Distance', 'sqEuclidean'); processKMeansResults( 'sqEuclidean', idx, gender, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName, DEBUG ); if(DEBUG == 1) disp('press space'); pause; end fprintf( fileOutputID, '\n' ); fclose( fileOutputID ); fprintf( fileKMeansOutputID, '\n' ); fclose( fileKMeansOutputID ); fprintf( masterFileOutputID, '\n' ); fclose( masterFileOutputID ); end