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

Examples of org.apache.mahout.cf.taste.impl.model.GenericDataModel


  public void testRescorer() throws Exception {
    List<User> users = new ArrayList<User>(3);
    users.add(getUser("test1", 0.1, 0.2));
    users.add(getUser("test2", 0.2, 0.3, 0.3, 0.6));
    users.add(getUser("test3", 0.4, 0.4, 0.5, 0.9));
    DataModel dataModel = new GenericDataModel(users);
    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(1, similarity, dataModel);
    Recommender recommender = new GenericUserBasedRecommender(dataModel, neighborhood, similarity);
    List<RecommendedItem> originalRecommended = recommender.recommend("test1", 2);
    List<RecommendedItem> rescoredRecommended =
View Full Code Here


    List<User> users = new ArrayList<User>(3);
    users.add(getUser("test1", 0.1, 0.2));
    users.add(getUser("test2", 0.2, 0.3, 0.3, 0.6));
    users.add(getUser("test3", 0.4, 0.4, 0.5, 0.9));
    users.add(getUser("test4"));
    DataModel dataModel = new GenericDataModel(users);
    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(3, similarity, dataModel);
    UserBasedRecommender recommender = new GenericUserBasedRecommender(dataModel, neighborhood, similarity);
    Collection<User> mostSimilar = recommender.mostSimilarUsers("test4", 3);
    assertNotNull(mostSimilar);
View Full Code Here

    assertNotNull(mostSimilar);
    assertEquals(0, mostSimilar.size());
  }

  private static UserBasedRecommender buildRecommender() throws Exception {
    DataModel dataModel = new GenericDataModel(getMockUsers());
    UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
    UserNeighborhood neighborhood = new NearestNUserNeighborhood(1, similarity, dataModel);
    return new GenericUserBasedRecommender(dataModel, neighborhood, similarity);
  }
View Full Code Here

  public void testRescorer() throws Exception {
    List<User> users = new ArrayList<User>(3);
    users.add(getUser("test1", 0.1, 0.2));
    users.add(getUser("test2", 0.2, 0.3, 0.3, 0.6));
    users.add(getUser("test3", 0.4, 0.4, 0.5, 0.9));
    DataModel dataModel = new GenericDataModel(users);
    Recommender recommender = new SlopeOneRecommender(dataModel);
    List<RecommendedItem> originalRecommended = recommender.recommend("test1", 2);
    List<RecommendedItem> rescoredRecommended =
            recommender.recommend("test1", 2, new ReversingRescorer<Item>());
    assertNotNull(originalRecommended);
View Full Code Here

  public void testBestRating() throws Exception {
    List<User> users = new ArrayList<User>(3);
    users.add(getUser("test1", 0.0, 0.3));
    users.add(getUser("test2", 0.2, 0.3, 0.3));
    users.add(getUser("test3", 0.4, 0.3, 0.5));
    DataModel dataModel = new GenericDataModel(users);
    Recommender recommender = new SlopeOneRecommender(dataModel);
    List<RecommendedItem> recommended = recommender.recommend("test1", 1);
    assertNotNull(recommended);
    assertEquals(1, recommended.size());
    RecommendedItem firstRecommended = recommended.get(0);
View Full Code Here

  public void testDiffStdevBehavior() throws Exception {
    List<User> users = new ArrayList<User>(3);
    users.add(getUser("test1", 0.1, 0.2));
    users.add(getUser("test2", 0.2, 0.3, 0.6));
    DataModel dataModel = new GenericDataModel(users);
    Recommender recommender = new SlopeOneRecommender(dataModel);
    assertEquals(0.6, recommender.estimatePreference("test1", "2"), EPSILON);
  }
View Full Code Here

    Recommender recommender = new SlopeOneRecommender(dataModel);
    assertEquals(0.6, recommender.estimatePreference("test1", "2"), EPSILON);
  }

  private static Recommender buildRecommender() throws TasteException {
    DataModel dataModel = new GenericDataModel(getMockUsers());
    return new SlopeOneRecommender(dataModel);
  }
View Full Code Here

* Tests {@link MemoryDiffStorage}.
*/
public class MemoryDiffStorageTest extends TasteTestCase {

  public void testGetDiff() throws Exception {
    DataModel model = new GenericDataModel(getMockUsers());
    MemoryDiffStorage storage = new MemoryDiffStorage(model, Weighting.UNWEIGHTED, false, Long.MAX_VALUE);
    RunningAverage average = storage.getDiff("1", "2");
    assertEquals(0.23333333333333334, average.getAverage(), EPSILON);
    assertEquals(3, average.getCount());
  }
View Full Code Here

    assertEquals(0.23333333333333334, average.getAverage(), EPSILON);
    assertEquals(3, average.getCount());
  }

  public void testUpdate() throws Exception {
    DataModel model = new GenericDataModel(getMockUsers());
    MemoryDiffStorage storage = new MemoryDiffStorage(model, Weighting.UNWEIGHTED, false, Long.MAX_VALUE);
    storage.updateItemPref("1", 0.5, false);
    RunningAverage average = storage.getDiff("1", "2");
    assertEquals(0.06666666666666668, average.getAverage(), EPSILON);
    assertEquals(3, average.getCount());
View Full Code Here

    assertEquals(0.06666666666666668, average.getAverage(), EPSILON);
    assertEquals(3, average.getCount());
  }

  public void testRemove() throws Exception {
    DataModel model = new GenericDataModel(getMockUsers());
    MemoryDiffStorage storage = new MemoryDiffStorage(model, Weighting.UNWEIGHTED, false, Long.MAX_VALUE);
    storage.updateItemPref("1", 0.5, true);
    RunningAverage average = storage.getDiff("1", "2");
    assertEquals(0.1, average.getAverage(), EPSILON);
    assertEquals(2, average.getCount());
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.impl.model.GenericDataModel

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.