protected double computeMse ( Classifier learner , Instances chunk ) { double mse_i = 0 ; double f_ci ; double voteSum ; for ( int i = 0 ; i < chunk . numInstances ( ) ; i ++ ) { try { voteSum = 0 ; for ( double element : learner . getVotesForInstance ( chunk . instance ( i ) ) ) { voteSum += element ; } if ( voteSum > 0 ) { f_ci = learner . getVotesForInstance ( chunk . instance ( i ) ) [ ( int ) chunk . instance ( i ) . classValue ( ) ] / voteSum ; mse_i += ( 1 - f_ci ) * ( 1 - f_ci ) ; } else { mse_i += 1 ; } } catch ( Exception e ) { mse_i += 1 ; } } mse_i /= this . chunkSizeOption . getValue ( ) ; return mse_i ; }
Computes the MSE of a learner for a given chunk of examples .