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

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


    FastByIDMap<PreferenceArray> result = new FastByIDMap<PreferenceArray>();
    for (int i = 0; i < userIDs.length; i++) {
      List<Preference> prefsList = new ArrayList<Preference>();
      for (int j = 0; j < prefValues[i].length; j++) {
        if (prefValues[i][j] != null) {
          prefsList.add(new GenericPreference(userIDs[i], j, prefValues[i][j].floatValue()));
        }
      }
      if (!prefsList.isEmpty()) {
        result.put(userIDs[i], new GenericUserPreferenceArray(prefsList));
      }
View Full Code Here


          break;
        }
      }
    } else {
      float preferenceValue = Float.parseFloat(preferenceValueString);
      prefs.add(new GenericPreference(userID, itemID, preferenceValue));
    }
  }
View Full Code Here

    Collection<Preference> prefs = new ArrayList<Preference>(count);
    for (int itemID = 1; itemID < jokePrefs.length; itemID++) { // yes skip first one, just a count
      String jokePref = jokePrefs[itemID];
      if (!"99".equals(jokePref)) {
        float jokePrefValue = Float.parseFloat(jokePref);
        prefs.add(new GenericPreference(userBeingRead, itemID, jokePrefValue));
      }
    }
    data.put(userBeingRead, prefs);
    userBeingRead++;
  }
View Full Code Here

    List<Preference> trainingPrefs = null;
    List<Preference> testPrefs = null;
    PreferenceArray prefs = dataModel.getPreferencesFromUser(userID);
    int size = prefs.length();
    for (int i = 0; i < size; i++) {
      Preference newPref = new GenericPreference(userID, prefs.getItemID(i), prefs.getValue(i));
      if (random.nextDouble() < trainingPercentage) {
        if (trainingPrefs == null) {
          trainingPrefs = new ArrayList<Preference>(3);
        }
        trainingPrefs.add(newPref);
View Full Code Here

    List<Preference> trainingPrefs = null;
    List<Preference> testPrefs = null;
    PreferenceArray prefs = dataModel.getPreferencesFromUser(userID);
    int size = prefs.length();
    for (int i = 0; i < size; i++) {
      Preference newPref = new GenericPreference(userID, prefs.getItemID(i), prefs.getValue(i));
      if (random.nextDouble() < trainingPercentage) {
        if (trainingPrefs == null) {
          trainingPrefs = new ArrayList<Preference>(3);
        }
        trainingPrefs.add(newPref);
View Full Code Here

  }

  // Some overrideable methods to customize the class behavior:

  protected Preference buildPreference(ResultSet rs) throws SQLException {
    return new GenericPreference(getLongColumn(rs, 1), getLongColumn(rs, 2), rs.getFloat(3));
  }
View Full Code Here

        if (!exists) {
          if (prefs == null) {
            prefs = new ArrayList<Preference>(2);
            ((FastByIDMap<Collection<Preference>>) data).put(userID, prefs);
          }
          prefs.add(new GenericPreference(userID, itemID, preferenceValue));
        }

        addTimestamp(userID, itemID, timestampString, timestamps);

      }
View Full Code Here

    FastByIDMap<PreferenceArray> result = new FastByIDMap<PreferenceArray>();
    for (int i = 0; i < userIDs.length; i++) {
      List<Preference> prefsList = new ArrayList<Preference>();
      for (int j = 0; j < prefValues[i].length; j++) {
        if (prefValues[i][j] != null) {
          prefsList.add(new GenericPreference(userIDs[i], j, prefValues[i][j].floatValue()));
        }
      }
      if (!prefsList.isEmpty()) {
        result.put(userIDs[i], new GenericUserPreferenceArray(prefsList));
      }
View Full Code Here

public final class SamplingCandidateItemsStrategyTest extends TasteTestCase {

  @Test
  public void testStrategy() throws TasteException {
    List<Preference> prefsOfUser123 = new ArrayList<Preference>();
    prefsOfUser123.add(new GenericPreference(123L, 1L, 1.0f));

    List<Preference> prefsOfUser456 = new ArrayList<Preference>();
    prefsOfUser456.add(new GenericPreference(456L, 1L, 1.0f));
    prefsOfUser456.add(new GenericPreference(456L, 2L, 1.0f));

    List<Preference> prefsOfUser789 = new ArrayList<Preference>();
    prefsOfUser789.add(new GenericPreference(789L, 1L, 0.5f));
    prefsOfUser789.add(new GenericPreference(789L, 3L, 1.0f));

    GenericUserPreferenceArray prefArrayOfUser123 = new GenericUserPreferenceArray(prefsOfUser123);

    FastByIDMap<PreferenceArray> userData = new FastByIDMap<PreferenceArray>();
    userData.put(123L, prefArrayOfUser123);
View Full Code Here

    DataModel dataModel = EasyMock.createMock(DataModel.class);
    EasyMock.expect(dataModel.getNumItems()).andReturn(3);
    EasyMock.expect(dataModel.getItemIDs()).andReturn(allItemIDs.iterator());

    PreferenceArray prefArrayOfUser123 = new GenericUserPreferenceArray(Arrays.asList(
        new GenericPreference(123L, 2L, 1.0f)));

    CandidateItemsStrategy strategy = new AllUnknownItemsCandidateItemsStrategy();

    EasyMock.replay(dataModel);
View Full Code Here

TOP

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

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.