public double query ( int targetClass , int targetValue , int [ ] cord ) { double sumVal = 0 ; double targetVal = 0 ; int realTargetIndex = catIndexToRealIndex [ targetClass ] ; CategoricalData queryData = valid . get ( targetClass ) ; //Now do all other target class posibilty querys for ( int i = 0 ; i < queryData . getNumOfCategories ( ) ; i ++ ) { cord [ realTargetIndex ] = i ; double tmp = countArray [ cordToIndex ( cord ) ] ; sumVal += tmp ; if ( i == targetValue ) targetVal = tmp ; } return targetVal / sumVal ; }
Queries the CPT for the probability of the target class occurring with the specified value given the class values of the other attributes