user2793047
user2793047

Reputation: 29

Mahout - Recommender Evaluator Returns 0.0

Alright, I'm VERY new to Mahout and java. I'm trying to evaluate a recommender and the code below returns 0.0 EVERY TIME, no matter the distance measure or cluster size I use. Clearly, it's not splitting the training and testing data at all, and I'm not sure why.

Any help with this code is appreciated!

public class Example {
public static void main(String[] args) throws Exception {

 final DataModel model = new FileDataModel(new File("FILENAME")) ;
  RecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();
  RecommenderBuilder recommenderBuilder = new RecommenderBuilder() {
      @Override
      public Recommender buildRecommender(DataModel dataModel) throws TasteException {
          UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
          ClusterSimilarity clusterSimilarity = new NearestNeighborClusterSimilarity(similarity);
          TreeClusteringRecommender tree = new TreeClusteringRecommender(model, clusterSimilarity, 50);
          return tree;
      }
  } ;
double score = evaluator.evaluate(recommenderBuilder, null, model, .7, 1.0);
    System.out.println(score);
    }
}

Thank you!

Upvotes: 1

Views: 905

Answers (2)

user3517559
user3517559

Reputation: 41

I believe it's because you are passing model as a parameter within your buildRecommender method. You have to use dataModel within that method when passing the DataModel to things like PearsonCorrelation, NearestNeighborClusterSimilarity, etc.

If you don't, you end up evaluating on the data model that contains all preferences meaning it will attempt to estimate a preference, find it already exists, and return the value. So you will always have perfect recommendation since the DataModel model already knows the preferences.

Upvotes: 4

Daehee Han
Daehee Han

Reputation: 526

from mahout documentation,

https://builds.apache.org/job/Mahout-Quality/javadoc/org/apache/mahout/cf/taste/eval/RecommenderEvaluator.html#evaluate(org.apache.mahout.cf.taste.eval.RecommenderBuilder, org.apache.mahout.cf.taste.eval.DataModelBuilder, org.apache.mahout.cf.taste.model.DataModel, double, double)

evaluate() 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

I guess you're ok.

Upvotes: -1

Related Questions