Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prediction for User-Item using PMFRecommender or NMFRecommender #329

Open
srinivasaraov opened this issue Jun 8, 2020 · 0 comments
Open

Comments

@srinivasaraov
Copy link

I am using the following code to build a model using PMFRecommender. If I want to get all recommendations for a particular user, instead of calling getRecommendedList() and filtering for the user, is there a method, say predict(user) that returns items with score for a particular user?

Also,

  • RecommenderSimilarity is not required to be added to the RecommenderContext if we are using Matrix Factorization algorithms, right?

  • What configuration parameters are available and possible values for PMFRecommender and NMFRecommender ?

  • I get a precision and recall values as following for the following code and config. Is the code correct or is there anything I am missing? Precision: NaN Recall: 0.0

  • Also, the recommended list keeps changing for every run? Is there a property I need to set to keep the recommendations constant?

  • How can I specify ARFF input instead of text and get the predictions ?

             ```
      Configuration conf = new Configuration();
      Resource resource = new Resource("pmf-test.properties");
      conf.addResource(resource);
    
      // build data model
      DataModel dataModel = new TextDataModel(conf);
      dataModel.buildDataModel();
    
      // set recommendation context
      RecommenderContext context = new RecommenderContext(conf, dataModel);
      // RecommenderSimilarity similarity = new PCCSimilarity();
      // similarity.buildSimilarityMatrix(dataModel);
      // context.setSimilarity(similarity);
    
      // training
      Recommender recommender = new PMFRecommender();
      recommender.recommend(context);
    
      // evaluation
      RecommenderEvaluator maeEvaluator = new MAEEvaluator();
      double mae = recommender.evaluate(maeEvaluator);
      
      RecommenderEvaluator rmseEvaluator = new RMSEEvaluator();
      double rmse = recommender.evaluate(rmseEvaluator);
      
      RecommenderEvaluator precisionEvaluator = new PrecisionEvaluator();
      double precision = recommender.evaluate(precisionEvaluator);
      
      RecommenderEvaluator recallEvaluator = new RecallEvaluator();
      double recall = recommender.evaluate(recallEvaluator);
      
      System.out.println("MAE:" + mae);
      System.out.println("RMSE:" + rmse);
      System.out.println("Precision: " + precision);
      System.out.println("Recall: " + recall);
    
      // recommendation results
      List<RecommendedItem> recommendedItemList = recommender.getRecommendedList();
      List<String> userIds = new ArrayList<String>();
      userIds.add("836");
      RecommendedFilter filter = new GenericRecommendedFilter();
      ((GenericRecommendedFilter) filter).setUserIdList(userIds);
      recommendedItemList = filter.filter(recommendedItemList);
      
      Map<String, Double> recommendedItems = new HashMap<String, Double>();
      System.out.println("Recommendations for User 836");
      for(RecommendedItem item : recommendedItemList) {
      	if(item.getUserId().equals("836")) {
      		System.out.println(item.getUserId() + " : " + item.getItemId() + " : " + item.getValue());
      	}
      }
    

//Config:

dfs.data.dir=/Users/sv/Datasets/
dfs.result.dir=/Users/sv/Datasets/

data.input.path=ml-100k/ratings.txt
data.column.format=UIR
data.model.splitter=ratio
data.splitter.ratio=rating
data.model.format=text
data.splitter.trainset.ratio=0.8

rec.random.seed=1
data.convert.binarize.threshold=-1.0

rec.eval.enable=true
rec.recommender.isranking=false

rec.recommender.class=pmf
rec.iterator.learnrate=0.01
rec.iterator.learnrate.maximum=0.01
rec.iterator.maximum=50
rec.user.regularization=0.08
rec.item.regularization=0.08
rec.factor.number=6
rec.learnrate.bolddriver=false
rec.learnrate.decay=1.0


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant