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

Examples of org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender


  @Test
  public void testFile() throws Exception {
    UserSimilarity userSimilarity = new PearsonCorrelationSimilarity(model);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(3, userSimilarity, model);
    Recommender recommender = new GenericUserBasedRecommender(model, neighborhood, userSimilarity);
    assertEquals(1, recommender.recommend(123, 3).size());
    assertEquals(0, recommender.recommend(234, 3).size());
    assertEquals(1, recommender.recommend(345, 3).size());

    // Make sure this doesn't throw an exception
    model.refresh(null);
  }
View Full Code Here


  @Test
  public void testFile() throws Exception {
    UserSimilarity userSimilarity = new PearsonCorrelationSimilarity(model);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(3, userSimilarity, model);
    Recommender recommender = new GenericUserBasedRecommender(model, neighborhood, userSimilarity);
    assertEquals(1, recommender.recommend(123, 3).size());
    assertEquals(0, recommender.recommend(234, 3).size());
    assertEquals(1, recommender.recommend(345, 3).size());

    // Make sure this doesn't throw an exception
    model.refresh(null);
  }
View Full Code Here

      System.out.println("Similarity between Wolf and Rabbit: "+pearsonSimilarity.userSimilarity(id2thing.toLongID("Wolf"), id2thing.toLongID("Rabbit")));
      // Similarity between Wolf and Pinguin: -0.24019223070763077
      // R: cor(c(8,3,1),c(2,10,2)): -0.2401922
      System.out.println("Similarity between Wolf and Pinguin: "+pearsonSimilarity.userSimilarity(id2thing.toLongID("Wolf"), id2thing.toLongID("Pinguin")));
     
      GenericUserBasedRecommender recommender = new GenericUserBasedRecommender(model, new NearestNUserNeighborhood(3, pearsonSimilarity, model), pearsonSimilarity);
      for(RecommendedItem r : recommender.recommend(id2thing.toLongID("Wolf"), 3)) {
        // Pork:
        // (0.8196561646738477 * 8 + (-0.6465846072812313) * 1) / (0.8196561646738477 + (-0.6465846072812313)) = 34,15157 ~ 10
        // Grass:
        // (2*(-0.24019223070763077)+7*(-0.6465846072812313)) / ((-0.24019223070763077) + (-0.6465846072812313)) = 5,65
        // Corn:
View Full Code Here

    UserNeighborhood neighborhood =
        new NearestNUserNeighborhood(
            100, similarity, model);

    Recommender recommender =  new GenericUserBasedRecommender(
        model, neighborhood, similarity);

    Recommender cachingRecommender = new CachingRecommender(recommender);

    for(int userId: userIds) {
View Full Code Here

      UserNeighborhood neighborhood =
          new NearestNUserNeighborhood(
              100,
              similarity, model);

      return new GenericUserBasedRecommender(
          model, neighborhood, similarity);
    }
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender

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.