protected double [ ] weightedMax ( Instance inst ) { int countFired = 0 ; boolean fired = false ; double highest = 0.0 ; double [ ] votes = new double [ this . numClass ] ; ArrayList < Double > ruleSetVotes = new ArrayList < Double > ( ) ; ArrayList < ArrayList < Double > > majorityProb = new ArrayList < ArrayList < Double > > ( ) ; for ( int j = 0 ; j < this . ruleSet . size ( ) ; j ++ ) { ArrayList < Double > ruleProb = new ArrayList < Double > ( ) ; if ( this . ruleSet . get ( j ) . ruleEvaluate ( inst ) == true ) { countFired = countFired + 1 ; for ( int z = 0 ; z < this . numClass ; z ++ ) { ruleSetVotes . add ( this . ruleSet . get ( j ) . obserClassDistrib . getValue ( z ) / this . ruleSet . get ( j ) . obserClassDistrib . sumOfValues ( ) ) ; ruleProb . add ( this . ruleSet . get ( j ) . obserClassDistrib . getValue ( z ) / this . ruleSet . get ( j ) . obserClassDistrib . sumOfValues ( ) ) ; } majorityProb . add ( ruleProb ) ; } } if ( countFired > 0 ) { fired = true ; Collections . sort ( ruleSetVotes ) ; highest = ruleSetVotes . get ( ruleSetVotes . size ( ) - 1 ) ; for ( int t = 0 ; t < majorityProb . size ( ) ; t ++ ) { for ( int m = 0 ; m < majorityProb . get ( t ) . size ( ) ; m ++ ) { if ( majorityProb . get ( t ) . get ( m ) == highest ) { for ( int h = 0 ; h < majorityProb . get ( t ) . size ( ) ; h ++ ) { votes [ h ] = majorityProb . get ( t ) . get ( h ) ; } break ; } } } } else { fired = false ; } if ( fired == false ) { votes = oberversDistribProb ( inst , this . observedClassDistribution ) ; } return votes ; }
Get the votes using weighted Max