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

Examples of org.apache.mahout.cf.taste.model.Preference


    if (preferenceValueString.length() == 0) {
      // remove pref
      Iterator<Preference> prefsIterator = prefs.iterator();
      while (prefsIterator.hasNext()) {
        Preference pref = prefsIterator.next();
        if (pref.getItemID() == itemID) {
          prefsIterator.remove();
          break;
        }
      }
    } else {
View Full Code Here


      List<Preference> prefs2 = new ArrayList<Preference>(prefs2Array.length());
      for (Preference pref : prefs2Array) {
        prefs2.add(pref);
      }
      for (Iterator<Preference> iterator = prefs2.iterator(); iterator.hasNext();) {
        Preference pref = iterator.next();
        if (relevantItemIDs.contains(pref.getItemID())) {
          iterator.remove();
        }
      }
      if (!prefs2.isEmpty()) {
       trainingUsers.put(userID2, new GenericUserPreferenceArray(prefs2));
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

  }

  public GenericItemPreferenceArray(List<Preference> prefs) {
    this(prefs.size());
    for (int i = 0; i < prefs.size(); i++) {
      Preference pref = prefs.get(i);
      IDs[i] = pref.getUserID();
      values[i] = pref.getValue();
    }
    id = prefs.get(0).getItemID();
  }
View Full Code Here

  }

  public BooleanItemPreferenceArray(List<Preference> prefs, boolean forOneUser) {
    this(prefs.size());
    for (int i = 0; i < prefs.size(); i++) {
      Preference pref = prefs.get(i);
      IDs[i] = forOneUser ? pref.getItemID() : pref.getUserID();
    }
    id = forOneUser ? prefs.get(0).getUserID() : prefs.get(0).getItemID();
  }
View Full Code Here

  }

  public GenericUserPreferenceArray(List<Preference> prefs) {
    this(prefs.size());
    for (int i = 0; i < prefs.size(); i++) {
      Preference pref = prefs.get(i);
      IDs[i] = pref.getItemID();
      values[i] = pref.getValue();
    }
    id = prefs.get(0).getUserID();
  }
View Full Code Here

  }

  public BooleanUserPreferenceArray(List<Preference> prefs) {
    this(prefs.size());
    for (int i = 0; i < prefs.size(); i++) {
      Preference pref = prefs.get(i);
      IDs[i] = pref.getItemID();
    }
    id = prefs.get(0).getUserID();
  }
View Full Code Here

  public GenericItemPreferenceArray(List<? extends Preference> prefs) {
    this(prefs.size());
    int size = prefs.size();
    long itemID = Long.MIN_VALUE;
    for (int i = 0; i < size; i++) {
      Preference pref = prefs.get(i);
      ids[i] = pref.getUserID();
      if (i == 0) {
        itemID = pref.getItemID();
      } else {
        if (itemID != pref.getItemID()) {
          throw new IllegalArgumentException("Not all item IDs are the same");
        }
      }
      values[i] = pref.getValue();
    }
    id = itemID;
  }
View Full Code Here

      List<Preference> prefs2 = new ArrayList<Preference>(prefs2Array.length());
      for (Preference pref : prefs2Array) {
        prefs2.add(pref);
      }
      for (Iterator<Preference> iterator = prefs2.iterator(); iterator.hasNext();) {
        Preference pref = iterator.next();
        if (relevantItemIDs.contains(pref.getItemID())) {
          iterator.remove();
        }
      }
      if (!prefs2.isEmpty()) {
        trainingUsers.put(userID2, new GenericUserPreferenceArray(prefs2));
View Full Code Here

 
  public BooleanItemPreferenceArray(List<? extends Preference> prefs, boolean forOneUser) {
    this(prefs.size());
    int size = prefs.size();
    for (int i = 0; i < size; i++) {
      Preference pref = prefs.get(i);
      ids[i] = forOneUser ? pref.getItemID() : pref.getUserID();
    }
    if (size > 0) {
      id = forOneUser ? prefs.get(0).getUserID() : prefs.get(0).getItemID();
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.model.Preference

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.