Package org.apache.mahout.cf.taste.recommender

Examples of org.apache.mahout.cf.taste.recommender.Recommender


  private LibimsetiLoadRunner() {
  }

  public static void main(String[] args) throws Exception {
    DataModel model = new FileDataModel(new File("ratings.dat"));
    Recommender rec = new LibimsetiRecommender(model);
    LoadEvaluator.runLoad(rec);
  }
View Full Code Here


  public static void main(String[] args) throws Exception {
    DataModel model = new GroupLensDataModel(new File("ratings.dat"));
    UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
    UserNeighborhood neighborhood =
      new NearestNUserNeighborhood(100, similarity, model);
    Recommender recommender =
      new GenericUserBasedRecommender(model, neighborhood, similarity);
    LoadEvaluator.runLoad(recommender);
  }
View Full Code Here

    }
   
    DataModel trainingModel = dataModelBuilder == null ? new GenericDataModel(trainingUsers)
        : dataModelBuilder.buildDataModel(trainingUsers);
   
    Recommender recommender = recommenderBuilder.buildRecommender(trainingModel);
   
    double result = getEvaluation(testUserPrefs, recommender);
    log.info("Evaluation result: {}", result);
    return result;
  }
View Full Code Here

                .nextLong(), dataModel);
          }
         
          DataModel trainingModel = dataModelBuilder == null ? new GenericDataModel(trainingUsers)
              : dataModelBuilder.buildDataModel(trainingUsers);
          Recommender recommender = recommenderBuilder.buildRecommender(trainingModel);
         
          try {
            trainingModel.getPreferencesFromUser(userID);
          } catch (NoSuchUserException nsee) {
            continue; // Oops we excluded all prefs for the user -- just move on
          }
         
          int intersectionSize = 0;
          List<RecommendedItem> recommendedItems = recommender.recommend(userID, at, rescorer);
          for (RecommendedItem recommendedItem : recommendedItems) {
            if (relevantItemIDs.contains(recommendedItem.getItemID())) {
              intersectionSize++;
            }
          }
View Full Code Here

    random = RandomUtils.getRandom();
  }

  public void testSlopeOneLoad() throws Exception {
    DataModel model = createModel();
    Recommender recommender = new CachingRecommender(new SlopeOneRecommender(model));
    doTestLoad(recommender, 60);
  }
View Full Code Here

  }

  public void testItemLoad() throws Exception {
    DataModel model = createModel();
    ItemSimilarity itemSimilarity = new PearsonCorrelationSimilarity(model);
    Recommender recommender = new CachingRecommender(new GenericItemBasedRecommender(model, itemSimilarity));
    doTestLoad(recommender, 240);
  }
View Full Code Here

  public void testUserLoad() throws Exception {
    DataModel model = createModel();
    UserSimilarity userSimilarity = new PearsonCorrelationSimilarity(model);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(10, userSimilarity, model);
    Recommender recommender =
        new CachingRecommender(new GenericUserBasedRecommender(model, neighborhood, userSimilarity));
    doTestLoad(recommender, 40);
  }
View Full Code Here

/** <p>Tests {@link GenericUserBasedRecommender}.</p> */
public final class GenericUserBasedRecommenderTest extends TasteTestCase {

  public void testRecommender() throws Exception {
    Recommender recommender = buildRecommender();
    List<RecommendedItem> recommended = recommender.recommend(1, 1);
    assertNotNull(recommended);
    assertEquals(1, recommended.size());
    RecommendedItem firstRecommended = recommended.get(0);
    assertEquals(2, firstRecommended.getItemID());
    assertEquals(0.3f, firstRecommended.getValue());
    recommender.refresh(null);
    assertEquals(2, firstRecommended.getItemID());
    assertEquals(0.3f, firstRecommended.getValue());
  }
View Full Code Here

                    {0.1, 0.4, 0.5, 0.8, 0.9, 1.0},
                    {0.2, 0.3, 0.6, 0.7, 0.1, 0.2},
            });
    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(2, similarity, dataModel);
    Recommender recommender = new GenericUserBasedRecommender(dataModel, neighborhood, similarity);
    List<RecommendedItem> fewRecommended = recommender.recommend(1, 2);
    List<RecommendedItem> moreRecommended = recommender.recommend(1, 4);
    for (int i = 0; i < fewRecommended.size(); i++) {
      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
    }
    recommender.refresh(null);
    for (int i = 0; i < fewRecommended.size(); i++) {
      assertEquals(fewRecommended.get(i).getItemID(), moreRecommended.get(i).getItemID());
    }
  }
View Full Code Here

                    {0.2, 0.3, 0.3, 0.6},
                    {0.4, 0.4, 0.5, 0.9},
            });
    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(1, similarity, dataModel);
    Recommender recommender = new GenericUserBasedRecommender(dataModel, neighborhood, similarity);
    List<RecommendedItem> originalRecommended = recommender.recommend(1, 2);
    List<RecommendedItem> rescoredRecommended =
        recommender.recommend(1, 2, new ReversingRescorer<Long>());
    assertNotNull(originalRecommended);
    assertNotNull(rescoredRecommended);
    assertEquals(2, originalRecommended.size());
    assertEquals(2, rescoredRecommended.size());
    assertEquals(originalRecommended.get(0).getItemID(), rescoredRecommended.get(1).getItemID());
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.recommender.Recommender

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.