@Override
    public double[] getVotesForInstance(Instance instance) {
        if (this.reset == true) {
            return new double[2];
        }
        double[] probOfClassGivenDoc = new double[m_numClasses];
        double totalSize = totalSize(instance);

        for (int i = 0; i < m_numClasses; i++) {
            probOfClassGivenDoc[i] = Math.log(m_probOfClass[i]) - totalSize * Math.log(m_classTotals[i]);
        }

        for (int i = 0; i < instance.numValues(); i++) {

            int index = instance.index(i);
            if (index == instance.classIndex() || instance.isMissing(i)) {
                continue;
            }

            double wordCount = instance.valueSparse(i);
            for (int c = 0; c < m_numClasses; c++) {
                double value = m_wordTotalForClass[c].getValue(index);
                probOfClassGivenDoc[c] += wordCount * Math.log(value == 0 ? this.laplaceCorrectionOption.getValue() : value );
            }
        }

        return Utils.logs2probs(probOfClassGivenDoc);
    }
@ Override public double [ ] getVotesForInstance ( Instance instance ) { if ( this . reset == true ) { return new double [ 2 ] ; } double [ ] probOfClassGivenDoc = new double [ m_numClasses ] ; double totalSize = totalSize ( instance ) ; for ( int i = 0 ; i < m_numClasses ; i ++ ) { probOfClassGivenDoc [ i ] = Math . log ( m_probOfClass [ i ] ) - totalSize * Math . log ( m_classTotals [ i ] ) ; } for ( int i = 0 ; i < instance . numValues ( ) ; i ++ ) { int index = instance . index ( i ) ; if ( index == instance . classIndex ( ) || instance . isMissing ( i ) ) { continue ; } double wordCount = instance . valueSparse ( i ) ; for ( int c = 0 ; c < m_numClasses ; c ++ ) { double value = m_wordTotalForClass [ c ] . getValue ( index ) ; probOfClassGivenDoc [ c ] += wordCount * Math . log ( value == 0 ? this . laplaceCorrectionOption . getValue ( ) : value ) ; } } return Utils . logs2probs ( probOfClassGivenDoc ) ; }
Calculates the class membership probabilities for the given test
instance.

@param instance the instance to be classified
@return predicted class probability distribution