/** * This method uses the trained parameters to make a binary decision about an example object. * * @param exampleFeatures The example's array of feature indices. * @param exampleValues The example's array of feature values. * @return The decision value. **/ public String discreteValue(int[] exampleFeatures, double[] exampleValues) { double[] scores = sumAlphas(exampleFeatures, exampleValues); return allowableValues[scores[0] > scores[1] ? 0 : 1]; }
/** * Returns the classification of the given example as a single feature instead of a * {@link FeatureVector}. * * @param exampleFeatures The example's array of feature indices. * @param exampleValues The example's array of feature values. * @return The classification of the example as a feature. **/ public Feature featureValue(int[] exampleFeatures, double[] exampleValues) { double[] scores = sumAlphas(exampleFeatures, exampleValues); return predictions.get(scores[0] > scores[1] ? 0 : 1); }
/** * Produces a set of scores indicating the degree to which each possible discrete classification * value is associated with the given example object. * * @param exampleFeatures The example's array of feature indices. * @param exampleValues The example's array of feature values. * @return The accumulated alpha values of weak learners that predicted the associated * classification value. **/ public ScoreSet scores(int[] exampleFeatures, double[] exampleValues) { double[] scores = sumAlphas(exampleFeatures, exampleValues); String[] values = new String[] {labelLexicon.lookupKey(0).getStringValue(), labelLexicon.lookupKey(1).getStringValue()}; return new ScoreSet(values, scores); }