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

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


  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


  public void testBestRating() throws Exception {
    Recommender recommender = buildRecommender();
    List<RecommendedItem> recommended = recommender.recommend(1, 1);
    assertNotNull(recommended);
    assertEquals(1, recommended.size());
    RecommendedItem firstRecommended = recommended.get(0);
    // item one should be recommended because it has a greater rating/score
    assertEquals(2, firstRecommended.getItemID());
    assertEquals(0.3f, firstRecommended.getValue(), EPSILON);
  }
View Full Code Here

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

  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.34803885284992736, firstRecommended.getValue(), EPSILON);
    recommender.refresh(null);
    assertEquals(2, firstRecommended.getItemID());
    assertEquals(0.34803885284992736, firstRecommended.getValue(), EPSILON);
  }
View Full Code Here

    ClusterSimilarity clusterSimilarity = new FarthestNeighborClusterSimilarity(similarity);
    Recommender recommender = new TreeClusteringRecommender(dataModel, clusterSimilarity, 2);
    List<RecommendedItem> recommended = recommender.recommend(1, 1);
    assertNotNull(recommended);
    assertEquals(1, recommended.size());
    RecommendedItem firstRecommended = recommended.get(0);
    // item one should be recommended because it has a greater rating/score
    assertEquals(2, firstRecommended.getItemID());
    assertEquals(0.3, firstRecommended.getValue(), EPSILON);
  }
View Full Code Here

    Recommender recommender = new SlopeOneRecommender(dataModel);
    List<RecommendedItem> recommended = recommender.recommend(1, 1);
    assertNotNull(recommended);
    assertEquals(1, recommended.size());
    RecommendedItem firstRecommended = recommended.get(0);
    // item one should be recommended because it has a greater rating/score
    assertEquals(2, firstRecommended.getItemID());
    assertEquals(0.2400938676203033, firstRecommended.getValue(), EPSILON);
  }
View Full Code Here

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

  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.18, firstRecommended.getValue(), EPSILON);
    recommender.refresh(null);
    recommended = recommender.recommend(1, 1);
    firstRecommended = recommended.get(0);   
    assertEquals(2, firstRecommended.getItemID());
    assertEquals(0.18, firstRecommended.getValue(), EPSILON);
  }
View Full Code Here

  public void testBestRating() throws Exception {
    Recommender recommender = buildRecommender();
    List<RecommendedItem> recommended = recommender.recommend(1, 1);
    assertNotNull(recommended);
    assertEquals(1, recommended.size());
    RecommendedItem firstRecommended = recommended.get(0);
    // item one should be recommended because it has a greater rating/score
    assertEquals(2, firstRecommended.getItemID());
    assertEquals(0.18, firstRecommended.getValue(), EPSILON);
  }
View Full Code Here

  public void testMostSimilar() throws Exception {
    ItemBasedRecommender recommender = buildRecommender();
    List<RecommendedItem> similar = recommender.mostSimilarItems(0, 2);
    assertNotNull(similar);
    assertEquals(2, similar.size());
    RecommendedItem first = similar.get(0);
    RecommendedItem second = similar.get(1);
    assertEquals(1, first.getItemID());
    assertEquals(1.0, first.getValue(), EPSILON);
    assertEquals(2, second.getItemID());
    assertEquals(0.5, second.getValue(), EPSILON);
  }
View Full Code Here

TOP

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

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.