@ Override public void buildClassifier ( Database database , Relation < ? extends ClassLabel > labelrep ) { Object2IntOpenHashMap < ClassLabel > count = new Object2IntOpenHashMap <> ( ) ; for ( DBIDIter iter = labelrep . iterDBIDs ( ) ; iter . valid ( ) ; iter . advance ( ) ) { count . addTo ( labelrep . get ( iter ) , 1 ) ; } int max = Integer . MIN_VALUE ; double size = labelrep . size ( ) ; distribution = new double [ count . size ( ) ] ; labels = new ArrayList <> ( count . size ( ) ) ; ObjectIterator < Entry < ClassLabel > > iter = count . object2IntEntrySet ( ) . fastIterator ( ) ; for ( int i = 0 ; iter . hasNext ( ) ; ++ i ) { Entry < ClassLabel > entry = iter . next ( ) ; distribution [ i ] = entry . getIntValue ( ) / size ; labels . add ( entry . getKey ( ) ) ; if ( entry . getIntValue ( ) > max ) { max = entry . getIntValue ( ) ; prediction = entry . getKey ( ) ; } } }
Learns the prior probability for all classes .