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);
    Item item1 = new GenericItem<String>("0");
    Item item2 = new GenericItem<String>("1");
    Item item3 = new GenericItem<String>("2");
    Item item4 = new GenericItem<String>("3");
    Collection<GenericItemSimilarity.ItemItemSimilarity> similarities =
View Full Code Here


    assertEquals("0", third.getItem().getID());
    assertEquals(0.2, third.getValue(), EPSILON);
  }

  private static ItemBasedRecommender buildRecommender() {
    DataModel dataModel = new GenericDataModel(getMockUsers());
    Collection<GenericItemSimilarity.ItemItemSimilarity> similarities =
            new ArrayList<GenericItemSimilarity.ItemItemSimilarity>(2);
    Item item1 = new GenericItem<String>("0");
    Item item2 = new GenericItem<String>("1");
    Item item3 = new GenericItem<String>("2");
View Full Code Here

    List<User> users = new ArrayList<User>(4);
    users.add(getUser("test1", 0.1, 0.3, 0.9, 0.8));
    users.add(getUser("test2", 0.2, 0.3, 0.3, 0.4));
    users.add(getUser("test3", 0.4, 0.3, 0.5, 0.1, 0.1));
    users.add(getUser("test4", 0.7, 0.3, 0.8, 0.5, 0.6));
    DataModel dataModel = new GenericDataModel(users);
    Collection<GenericItemSimilarity.ItemItemSimilarity> similarities =
            new ArrayList<GenericItemSimilarity.ItemItemSimilarity>(10);
    Item item1 = new GenericItem<String>("0");
    Item item2 = new GenericItem<String>("1");
    Item item3 = new GenericItem<String>("2");
View Full Code Here

    users.add(getUser("test1", 0.1));
    users.add(getUser("test2", 0.2, 0.3));
    users.add(getUser("test3", 0.4, 0.5, 0.6));
    users.add(getUser("test4", 0.7, 0.8, 0.9, 1.0));
    users.add(getUser("test5", 1.0, 1.0, 1.0, 1.0, 1.0));
    GenericDataModel dummy = new GenericDataModel(users);
    InverseUserFrequency iuf = new InverseUserFrequency(dummy, 10.0);

    User user = dummy.getUser("test5");
    for (int i = 0; i < 5; i++) {
      Preference pref = user.getPreferenceFor(String.valueOf(i));
      assertNotNull(pref);
      assertEquals(Math.log(5.0 / (double) (5 - i)) / Math.log(iuf.getLogBase()),
                   iuf.getTransformedValue(pref),
View Full Code Here

    try {
      // Load new in-memory representation,
      log.info("Loading new JDBC delegate data...");
      DataModel newDelegateInMemory =
          delegate.hasPreferenceValues()
          ? new GenericDataModel(delegate.exportWithPrefs())
          : new GenericBooleanPrefDataModel(delegate.exportWithIDsOnly());
      // and then swap to it.
      log.info("New data loaded.");
      delegateInMemory = newDelegateInMemory;
    } catch (TasteException te) {
View Full Code Here

        for (File updateFile : findUpdateFilesAfter(newLastModified)) {
          processFile(new FileLineIterator(updateFile, false), data, timestamps, false);
        }

        return new GenericDataModel(GenericDataModel.toDataMap(data, true), timestamps);

      } else {

        FastByIDMap<PreferenceArray> rawData = ((GenericDataModel) delegate).getRawUserData();

        for (File updateFile : findUpdateFilesAfter(Math.max(oldLastUpdateFileModifieid, newLastModified))) {
          processFile(new FileLineIterator(updateFile, false), rawData, timestamps, true);
        }

        return new GenericDataModel(rawData, timestamps);

      }

    } else {
View Full Code Here

  protected DataModel buildModel() throws IOException {
    FastByIDMap<Collection<Preference>> data = new FastByIDMap<Collection<Preference>>();
    FileLineIterator iterator = new FileLineIterator(getDataFile(), false);
    FastByIDMap<FastByIDMap<Long>> timestamps = new FastByIDMap<FastByIDMap<Long>>();
    processFile(iterator, data, timestamps, false);
    return new GenericDataModel(GenericDataModel.toDataMap(data, true));
  }
View Full Code Here

      LongPrimitiveIterator it2 = dataModel.getUserIDs();
      while (it2.hasNext()) {
        dataSplitter.processOtherUser(userID, relevantItemIDs, trainingUsers, it2.nextLong(), dataModel);
      }

      DataModel trainingModel = dataModelBuilder == null ? new GenericDataModel(trainingUsers)
          : dataModelBuilder.buildDataModel(trainingUsers);
      try {
        trainingModel.getPreferencesFromUser(userID);
      } catch (NoSuchUserException nsee) {
        continue; // Oops we excluded all prefs for the user -- just move on
View Full Code Here

                                                                  new GenericPreference(3L, 4L, 3.0f))));

    userData.put(4L, new GenericUserPreferenceArray(Arrays.asList(new GenericPreference(4L, 1L, 3.0f),
                                                                  new GenericPreference(4L, 4L, 5.0f))));

    dataModel = new GenericDataModel(userData);
    factorizer = new ALSWRFactorizer(dataModel, 3, 0.065, 10);
  }
View Full Code Here

      }

      userData.put(userIndex, new GenericUserPreferenceArray(row));
    }

    dataModel = new GenericDataModel(userData);
  }
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.