protected double [ ] weightedSum ( Instance inst ) { boolean fired = false ; int countFired = 0 ; double [ ] votes = new double [ this . numClass ] ; ArrayList < Double > weightSum = 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 ++ ) { ruleProb . add ( this . ruleSet . get ( j ) . obserClassDistrib . getValue ( z ) / this . ruleSet . get ( j ) . obserClassDistrib . sumOfValues ( ) ) ; } majorityProb . add ( ruleProb ) ; } } if ( countFired > 0 ) { fired = true ; for ( int m = 0 ; m < majorityProb . get ( 0 ) . size ( ) ; m ++ ) { double sum = 0.0 ; for ( int t = 0 ; t < majorityProb . size ( ) ; t ++ ) { sum = sum + majorityProb . get ( t ) . get ( m ) ; } weightSum . add ( sum ) ; } for ( int h = 0 ; h < weightSum . size ( ) ; h ++ ) { votes [ h ] = weightSum . get ( h ) / majorityProb . size ( ) ; } } else { fired = false ; } if ( fired == false ) { votes = oberversDistribProb ( inst , this . observedClassDistribution ) ; } return votes ; }
Get the votes using weighted Sum