protected double computeWeight ( int i , Instance example ) { int d = this . windowSize ; int t = this . processedInstances - this . ensemble [ i ] . birthday ; double e_it = 0 ; double mse_it = 0 ; double voteSum = 0 ; try { double [ ] votes = this . ensemble [ i ] . classifier . getVotesForInstance ( example ) ; for ( double element : votes ) { voteSum += element ; } if ( voteSum > 0 ) { double f_it = 1 - ( votes [ ( int ) example . classValue ( ) ] / voteSum ) ; e_it = f_it * f_it ; } else { e_it = 1 ; } } catch ( Exception e ) { e_it = 1 ; } if ( t > d ) { mse_it = this . ensemble [ i ] . mse_it + e_it / ( double ) d - this . ensemble [ i ] . squareErrors [ t % d ] / ( double ) d ; } else { mse_it = this . ensemble [ i ] . mse_it * ( t - 1 ) / t + e_it / ( double ) t ; } this . ensemble [ i ] . squareErrors [ t % d ] = e_it ; this . ensemble [ i ] . mse_it = mse_it ; if ( linearOption . isSet ( ) ) { return java . lang . Math . max ( mse_r - mse_it , Double . MIN_VALUE ) ; } else { return 1.0 / ( this . mse_r + mse_it + Double . MIN_VALUE ) ; } }
Computes the weight of a learner before training a given example .