简体   繁体   English

Mahout - 推荐评估员返回0.0

[英]Mahout - Recommender Evaluator Returns 0.0

Alright, I'm VERY new to Mahout and java. 好吧,我对Mahout和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. 我正在尝试评估推荐器,无论我使用的距离度量或簇大小,下面的代码都会返回0.0。 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! 谢谢!

I believe it's because you are passing model as a parameter within your buildRecommender method. 我相信这是因为您将模型作为buildRecommender方法中的参数传递。 You have to use dataModel within that method when passing the DataModel to things like PearsonCorrelation, NearestNeighborClusterSimilarity, etc. 在将DataModel传递给PearsonCorrelation,NearestNeighborClusterSimilarity等内容时,必须在该方法中使用dataModel。

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. 因此,您将始终拥有完美的推荐,因为DataModel模型已经知道了首选项。

from mahout documentation, 来自mahout文档,

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) 自由软件网站建设 : 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; evaluate()返回:一个“得分”,表示推荐者的估计偏好与实际值的匹配程度; lower scores mean a better match and 0 is a perfect match 较低的分数意味着更好的匹配,0是完美的匹配

I guess you're ok. 我猜你没事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM