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

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


public final class AveragingPreferenceInferrerTest extends TasteTestCase {

  public void testInferrer() throws TasteException {
    User user1 = getUser("test1", 3.0, -2.0, 5.0);
    Item item = new GenericItem<String>("3");
    DataModel model = new GenericDataModel(Collections.singletonList(user1));
    PreferenceInferrer inferrer = new AveragingPreferenceInferrer(model);
    double inferred = inferrer.inferPreference(user1, item);
    assertEquals(2.0, inferred);
  }
View Full Code Here


    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", 0.1, 0.4, 0.5, 0.8, 0.9, 1.0));
    users.add(getUser("test5", 0.2, 0.3, 0.6, 0.7, 0.1, 0.2));
    DataModel dataModel = new GenericDataModel(users);
    Recommender recommender = new SlopeOneRecommender(dataModel);
    List<RecommendedItem> fewRecommended = recommender.recommend("test1", 2);
    List<RecommendedItem> moreRecommended = recommender.recommend("test1", 4);
    for (int i = 0; i < fewRecommended.size(); i++) {
      assertEquals(fewRecommended.get(i).getItem(), moreRecommended.get(i).getItem());
View Full Code Here

    }
    return new GenericUser<String>(userID, prefs);
  }

  public static DataModel getDataModel(User... users) {
    return new GenericDataModel(Arrays.asList(users));
  }
View Full Code Here

public final class NearestNNeighborhoodTest extends TasteTestCase {

  public void testNeighborhood() throws Exception {

    List<User> users = getMockUsers();
    DataModel dataModel = new GenericDataModel(users);

    Collection<User> neighborhood =
            new NearestNUserNeighborhood(1, new DummySimilarity(), dataModel).getUserNeighborhood("test1");
    assertNotNull(neighborhood);
    assertEquals(1, neighborhood.size());
View Full Code Here

  public static DataModel getDataModel(User... users) {
    return new GenericDataModel(Arrays.asList(users));
  }

  public static DataModel getDataModel() {
    return new GenericDataModel(getMockUsers());
  }
View Full Code Here

  }

  public void testRefresh() throws Exception {
    // Make sure this doesn't throw an exception
    DataModel dataModel = new GenericDataModel(Collections.singletonList(getUser("test1", 0.1)));
    new NearestNUserNeighborhood(1, new DummySimilarity(), dataModel).refresh(null);
  }
View Full Code Here

public final class ThresholdNeighborhoodTest extends TasteTestCase {

  public void testNeighborhood() throws Exception {

    List<User> users = getMockUsers();
    DataModel dataModel = new GenericDataModel(users);

    Collection<User> neighborhood =
            new ThresholdUserNeighborhood(20.0, new DummySimilarity(), dataModel).getUserNeighborhood("test1");
    assertNotNull(neighborhood);
    assertTrue(neighborhood.isEmpty());
View Full Code Here

  }

  public void testRefresh() throws Exception {
    // Make sure this doesn't throw an exception
    DataModel dataModel = new GenericDataModel(Collections.singletonList(getUser("test1", 0.1)));
    new ThresholdUserNeighborhood(20.0, new DummySimilarity(), dataModel).refresh(null);
  }
View Full Code Here

      }
      GenericUser<String> user = new GenericUser<String>(String.valueOf(i), prefs);
      users.add(user);
    }

    return new GenericDataModel(users);
  }
View Full Code Here

    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", 0.1, 0.4, 0.5, 0.8, 0.9, 1.0));
    users.add(getUser("test5", 0.2, 0.3, 0.6, 0.7, 0.1, 0.2));
    DataModel dataModel = new GenericDataModel(users);
    Collection<GenericItemSimilarity.ItemItemSimilarity> similarities =
            new ArrayList<GenericItemSimilarity.ItemItemSimilarity>(6);
    for (int i = 0; i < 6; i++) {
      for (int j = i + 1; j < 6; j++) {
        similarities.add(
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.