@Override public ValueType getFirst() { return this.getValue(); }
@Override protected <ANNOTATION> List<ScoredAnnotation<ANNOTATION>> getAnnotations(VectorNaiveBayesCategorizer<ANNOTATION, PDF> categorizer, Vector vec) { final List<ScoredAnnotation<ANNOTATION>> results = new ArrayList<ScoredAnnotation<ANNOTATION>>(); final DefaultWeightedValueDiscriminant<ANNOTATION> r = categorizer.evaluateWithDiscriminant(vec); results.add(new ScoredAnnotation<ANNOTATION>(r.getValue(), (float) Math.exp(r.getWeight()))); return results; } };
/** * Convenience method for creating a new * {@code DefaultWeightedValueDiscriminant} with the given value and weight. * * @param <ValueType> * The type of value to discriminate between. * @param value * The value for the pair. * @param weight * The weight that is to be used as the discriminant. * @return * A new discriminant object. */ public static <ValueType> DefaultWeightedValueDiscriminant<ValueType> create( final ValueType value, final double weight) { return new DefaultWeightedValueDiscriminant<ValueType>(value, weight); }
new DefaultWeightedValueDiscriminant<CategoryType>(); result.setValue(minCat); result.setWeight(minDelta);
@Override public ValueDiscriminantPair<Boolean, Double> evaluateWithDiscriminant( final InputType input) { // Evaluate the input as a double whose sign is the category. final double value = this.evaluateAsDouble(input); final boolean category = value >= 0.0; // The discriminant needs to be larger for a better match, even in // the case of the false category, which requires doing an absolute // value to the sign. final double discriminant = category ? value : -value; return DefaultWeightedValueDiscriminant.create(category, discriminant); }
@Override public Double getDiscriminant() { return this.getWeight(); }
new DefaultWeightedValueDiscriminant<CategoryType>(); result.setValue(minCat); result.setWeight(minDelta);
@Override public ValueDiscriminantPair<Boolean, Double> evaluateWithDiscriminant( final InputType input) { // Evaluate the input as a double whose sign is the category. final double value = this.evaluateAsDouble(input); final boolean category = value >= 0.0; // The discriminant needs to be larger for a better match, even in // the case of the false category, which requires doing an absolute // value to the sign. final double discriminant = category ? value : -value; return DefaultWeightedValueDiscriminant.create(category, discriminant); }
@Override public Double getSecond() { return this.getWeight(); }
new DefaultWeightedValueDiscriminant<CategoryType>(); result.setValue(minCat); result.setWeight(minDelta);
@Override public ValueType getFirst() { return this.getValue(); }
@Override public ValueDiscriminantPair<Boolean, Double> evaluateWithDiscriminant( final InputType input) { // Evaluate the input as a double whose sign is the category. final double value = this.evaluateAsDouble(input); final boolean category = value >= 0.0; // The discriminant needs to be larger for a better match, even in // the case of the false category, which requires doing an absolute // value to the sign. final double discriminant = category ? value : -value; return DefaultWeightedValueDiscriminant.create(category, discriminant); }
@Override public Double getDiscriminant() { return this.getWeight(); }
/** * Convenience method for creating a new * {@code DefaultWeightedValueDiscriminant} with the given value and weight. * * @param <ValueType> * The type of value to discriminate between. * @param value * The value for the pair. * @param weight * The weight that is to be used as the discriminant. * @return * A new discriminant object. */ public static <ValueType> DefaultWeightedValueDiscriminant<ValueType> create( final ValueType value, final double weight) { return new DefaultWeightedValueDiscriminant<ValueType>(value, weight); }
new DefaultWeightedValueDiscriminant<CategoryType>(); result.setValue(minCat); result.setWeight(minDelta);
@Override public ValueType getFirst() { return this.getValue(); }
@Override public DefaultWeightedValueDiscriminant<CategoryType> evaluateWithDiscriminant( final ObservationType input) { CategoryType maxCategory = null; double maxPosterior = Double.NEGATIVE_INFINITY; for( CategoryType category : this.getCategories() ) { double posterior = this.computePosterior(input, category); if( maxPosterior < posterior ) { maxPosterior = posterior; maxCategory = category; } } return DefaultWeightedValueDiscriminant.create(maxCategory, maxPosterior); }
@Override public Double getSecond() { return this.getWeight(); }
/** * Convenience method for creating a new * {@code DefaultWeightedValueDiscriminant} with the given value and weight. * * @param <ValueType> * The type of value to discriminate between. * @param value * The value for the pair. * @param weight * The weight that is to be used as the discriminant. * @return * A new discriminant object. */ public static <ValueType> DefaultWeightedValueDiscriminant<ValueType> create( final ValueType value, final double weight) { return new DefaultWeightedValueDiscriminant<ValueType>(value, weight); }
new DefaultWeightedValueDiscriminant<CategoryType>(); result.setValue(minCat); result.setWeight(minDelta);