// // MPT_LabEmotions.m // // Created by Andrew Salamon on March 3, 2008. // Copyright (c) 2008 Machine Perception Laboratory University of California San Diego. // #import "MPT_LabEmotions.h" #import @implementation MPT_LabEmotions - (NSDictionary *)postProcess:(NSDictionary *)svmResults { // Disable this per Gwen's request. return svmResults; // do softmax here /* If the 6 emotion outputs for a single frame is Yout_em y=exp(Yout_em*k); (k is a constant which may need tweeking. Try k=10;) s=sum(y)+1; yout=y/s; */ static const double k = 10.0; double s = 0.0; NSMutableDictionary *newResults = [NSMutableDictionary dictionary]; NSEnumerator *keyEnum = [[svmResults allKeys] objectEnumerator]; NSString *key; while( key = [keyEnum nextObject] ) { double value = [[svmResults objectForKey:key] doubleValue]; value = exp( value * k ); s += value; [newResults setObject:[NSNumber numberWithDouble:value] forKey:key]; } keyEnum = [[newResults allKeys] objectEnumerator]; while( key = [keyEnum nextObject] ) { double value = [[newResults objectForKey:key] doubleValue]; value /= s; [newResults setObject:[NSNumber numberWithDouble:value] forKey:key]; } return newResults; } - (void)setView:(MPT_AUView *)newView forLabel:(NSString *)label { [super setView:newView forLabel:label]; [newView setDefaultMin:0.0]; [newView setDefaultMax:1.0]; [newView resetDynamicRange]; } @end