public static AssociativeArray majorityVote ( DataTable2D classifierClassProbabilityMatrix ) { AssociativeArray combinedClassProbabilities = new AssociativeArray ( ) ; //extract all the classes first for ( Map . Entry < Object , AssociativeArray > entry : classifierClassProbabilityMatrix . entrySet ( ) ) { //Object classifier = entry.getKey(); AssociativeArray listOfClassProbabilities = entry . getValue ( ) ; for ( Map . Entry < Object , Object > entry2 : listOfClassProbabilities . entrySet ( ) ) { Object theClass = entry2 . getKey ( ) ; //Double probability = Dataset.toDouble(entry2.getValue()); combinedClassProbabilities . put ( theClass , 0.0 ) ; } } for ( Map . Entry < Object , AssociativeArray > entry : classifierClassProbabilityMatrix . entrySet ( ) ) { //Object classifier = entry.getKey(); AssociativeArray listOfClassProbabilities = entry . getValue ( ) ; Map . Entry < Object , Object > selectedClassEntry = MapMethods . selectMaxKeyValue ( listOfClassProbabilities ) ; Object theClass = selectedClassEntry . getKey ( ) ; Double previousValue = combinedClassProbabilities . getDouble ( theClass ) ; if ( previousValue == null ) { previousValue = 0.0 ; } combinedClassProbabilities . put ( theClass , previousValue + 1.0 ) ; } return combinedClassProbabilities ; }
Combines the responses of the classifiers by summing the votes of each winner class .