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

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


        Collection<Preference> userPrefs = userIDPrefMap.get(userID);
        if (userPrefs == null) {
          userPrefs = new ArrayList<Preference>(2);
          userIDPrefMap.put(userID, userPrefs);
        }
        userPrefs.add(new GenericPreference(userID, movieID, rating));
      }
    }
   
    return GenericDataModel.toDataMap(userIDPrefMap, true);
  }
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

    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

  }

  // 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

      int length = source.length;
      Preference[] sortedPrefs = new Preference[length];
      System.arraycopy(source, 0, sortedPrefs, 0, length);
      Arrays.sort(sortedPrefs, ByValuePreferenceComparator.getInstance());
      for (int i = 0; i < length; i++) {
        sortedPrefs[i] = new GenericPreference(this, sortedPrefs[i].getItem(), (double) (i + 1));
      }
      Arrays.sort(sortedPrefs, ByItemPreferenceComparator.getInstance());
      return sortedPrefs;
    }
View Full Code Here

        Item item = itemCache.get(itemID);
        if (item == null) {
          item = buildItem(itemID);
          itemCache.put(itemID, item);
        }
        prefs.add(new GenericPreference(null, item, jokePrefValue));
      }
    }
    data.put(userID, prefs);
    userBeingRead++;
  }
View Full Code Here

    for (String line : new FileLineIterable(movieFile, true)) {
      int firstComma = line.indexOf((int) ',');
      Integer userID = Integer.valueOf(line.substring(0, firstComma));
      int secondComma = line.indexOf((int) ',', firstComma + 1);
      double rating = Double.parseDouble(line.substring(firstComma + 1, secondComma));
      prefs.add(new GenericPreference(getUser(userID), movie, rating));
    }
    return prefs.toArray(new Preference[prefs.size()]);
  }
View Full Code Here

        List<Preference> userPrefs = userIDPrefMap.get(userID);
        if (userPrefs == null) {
          userPrefs = new ArrayList<Preference>();
          userIDPrefMap.put(userID, userPrefs);
        }
        userPrefs.add(new GenericPreference(null, movie, rating));
      }
    }

    List<User> users = new ArrayList<User>(userIDPrefMap.size());
    for (Map.Entry<Integer, List<Preference>> entry : userIDPrefMap.entrySet()) {
View Full Code Here

   * @param user {@link User}
   * @param item {@link Item}
   * @return {@link GenericPreference} by default
   */
  protected Preference buildPreference(User user, Item item, double value) {
    return new GenericPreference(user, item, value);
  }
View Full Code Here

                              User user) {
    List<Preference> trainingPrefs = new ArrayList<Preference>();
    List<Preference> testPrefs = new ArrayList<Preference>();
    Preference[] prefs = user.getPreferencesAsArray();
    for (Preference pref : prefs) {
      Preference newPref = new GenericPreference(null, pref.getItem(), pref.getValue());
      if (random.nextDouble() < trainingPercentage) {
        trainingPrefs.add(newPref);
      } else {
        testPrefs.add(newPref);
      }
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.