@Override
  public DefaultWeightedValueDiscriminant<CategoryType> evaluateWithDiscriminant(
      final Vectorizable input) {
    // Convert the input to a vector.
    final Vector inputVector = input.convertToVector();

    // Find the category that has the highest match.
    double bestScore = 0.0;
    CategoryType bestCategory = null;
    for (CategoryType category : this.getCategories()) {
      final double score = this.evaluateAsDouble(inputVector, category);

      if (bestCategory == null || score > bestScore) {
        bestScore = score;
        bestCategory = category;
      }
    }

    // Return the discriminant for the category.
    return new DefaultWeightedValueDiscriminant<CategoryType>(bestCategory, bestScore);
  }
 /**
  * Evaluates how much the given input matches the prototype for the given category.
  *
  * @param input The input.
  * @param category The category to match the input against.
  * @return A real value indicating how much the input matches the category. A larger value
  *     indicates a better match.
  */
 public double evaluateAsDouble(final Vectorizable input, final CategoryType category) {
   return this.evaluateAsDouble(input.convertToVector(), category);
 }
Exemplo n.º 3
0
 @Override
 public double evaluateAsDouble(final Vectorizable input) {
   return this.getWeightVector().dotProduct(input.convertToVector());
 }