## org.apache.mahout.cf.taste.impl.eval
Class AbstractDifferenceRecommenderEvaluator

    java.lang.Object
      org.apache.mahout.cf.taste.impl.eval.AbstractDifferenceRecommenderEvaluator

All Implemented Interfaces:
  RecommenderEvaluator

Direct Known Subclasses:
  AverageAbsoluteDifferenceRecommenderEvaluator, RMSRecommenderEvaluator

    public abstract class AbstractDifferenceRecommenderEvaluator

extends Object
implements RecommenderEvaluator

Abstract superclass of a couple implementations, providing shared functionality.

Nested Class Summary
`class` `AbstractDifferenceRecommenderEvaluator.PreferenceEstimateCallable`

Constructor Summary
`protected` `AbstractDifferenceRecommenderEvaluator()`

Method Summary
`protected abstract double` `computeFinalEvaluation()`
`double` `evaluate(RecommenderBuilder recommenderBuilder, DataModelBuilder dataModelBuilder, DataModel dataModel, double trainingPercentage, double evaluationPercentage)` Evaluates the quality of a `Recommender`'s recommendations.
`protected static void` `execute(Collection<Callable<Void>> callables, AtomicInteger noEstimateCounter, RunningAverageAndStdDev timing)`
`float` `getMaxPreference()`
`float` `getMinPreference()`
`protected abstract void` `processOneEstimate(float estimatedPreference, Preference realPref)`
`protected abstract void` `reset()`
`void` `setMaxPreference(float maxPreference)`
`void` `setMinPreference(float minPreference)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractDifferenceRecommenderEvaluator

    protected AbstractDifferenceRecommenderEvaluator()

Method Detail

### getMaxPreference

    public final float getMaxPreference()

  Specified by:
    `getMaxPreference` in interface `RecommenderEvaluator`

### setMaxPreference

    public final void setMaxPreference(float maxPreference)

  Specified by:
    `setMaxPreference` in interface `RecommenderEvaluator`

### getMinPreference

    public final float getMinPreference()

  Specified by:
    `getMinPreference` in interface `RecommenderEvaluator`

### setMinPreference

    public final void setMinPreference(float minPreference)

  Specified by:
    `setMinPreference` in interface `RecommenderEvaluator`

### evaluate

    public double evaluate(RecommenderBuilder recommenderBuilder,
                           DataModelBuilder dataModelBuilder,
                           DataModel dataModel,
                           double trainingPercentage,
                           double evaluationPercentage)
                    throws TasteException

  Description copied from interface: `RecommenderEvaluator`

  Evaluates the quality of a `Recommender`'s recommendations. The range of values that may be returned depends on the implementation, but lower values must mean better recommendations, with 0 being the lowest / best possible evaluation, meaning a perfect match. This method does not accept a `Recommender` directly, but rather a `RecommenderBuilder` which can build the `Recommender` to test on top of a given `DataModel`.

  Implementations will take a certain percentage of the preferences supplied by the given `DataModel` as "training data". This is typically most of the data, like 90%. This data is used to produce recommendations, and the rest of the data is compared against estimated preference values to see how much the `Recommender`'s predicted preferences match the user's real preferences. Specifically, for each user, this percentage of the user's ratings are used to produce recommendations, and for each user, the remaining preferences are compared against the user's real preferences.

  For large datasets, it may be desirable to only evaluate based on a small percentage of the data. `evaluationPercentage` controls how many of the `DataModel`'s users are used in evaluation.

  To be clear, `trainingPercentage` and `evaluationPercentage` are not related. They do not need to add up to 1.0, for example.

  Specified by:
    `evaluate` in interface `RecommenderEvaluator`
  Parameters:
    `recommenderBuilder` - object that can build a `Recommender` to test
    `dataModelBuilder` - `DataModelBuilder` to use, or if null, a default `DataModel` implementation will be used
    `dataModel` - dataset to test on
    `trainingPercentage` - percentage of each user's preferences to use to produce recommendations; the rest are compared to estimated preference values to evaluate `Recommender` performance
    `evaluationPercentage` - percentage of users to use in evaluation
  Returns:
    a "score" representing how well the `Recommender`'s estimated preferences match real values; lower scores mean a better match and 0 is a perfect match
  Throws:
    `TasteException` - if an error occurs while accessing the `DataModel`

### execute

    protected static void execute(Collection<Callable<Void>> callables,
                                  AtomicInteger noEstimateCounter,
                                  RunningAverageAndStdDev timing)
                           throws TasteException

  Throws:
    `TasteException`

### reset

    protected abstract void reset()

### processOneEstimate

    protected abstract void processOneEstimate(float estimatedPreference,
                                               Preference realPref)

### computeFinalEvaluation

    protected abstract double computeFinalEvaluation()

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.