NaiveBayes extends AbstractClassifier<Data,String> { @Override public String predict( Data item ){ Map<String,Double> probs = this.vote( item ); Double max = 0.0d; String maxClass = null; Double confidence = 0.0d; for( String clazz : probs.keySet() ){ Double likelihood = probs.get( clazz ); log.debug( "probability for {} is {}", clazz, likelihood ); if( maxClass == null || likelihood > max ){ maxClass = clazz; if( max != null ) confidence = 1.0d - Math.abs( likelihood - max ); else confidence = 1.0d; max = likelihood; } } log.info( "Predicting class {}, label is: {}, confidence-gap: " + confidence + " wop=" + wop, maxClass, item.get( labelAttribute ) ); return maxClass; } NaiveBayes();  NaiveBayes( String labelAttribute ); String getLabelAttribute(); void setLabelAttribute(String labelAttribute); Double getLaplaceCorrection(); void setLaplaceCorrection(Double laplaceCorrection); Double getConfidenceGap(); void setConfidenceGap(Double confidenceGap); Boolean getWop(); void setWop(Boolean wop); @SuppressWarnings("unchecked") Map<String,Double> vote(Data item); @Override String predict( Data item ); String getNominalCondition( String attribute, Data item ); @SuppressWarnings("unchecked") @Override void learn(Data item); Distribution<String> getClassDistribution(); @SuppressWarnings("unchecked") List<Distribution<Double>> getNumericalDistributions(); Distribution<String> createNominalDistribution(); Distribution<Double> createNumericalDistribution();  }
@Test public void testPredict() { }