Examples of GenericPreference


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

      for (String line : new FileLineIterable(movieFile, true)) {
        int firstComma = line.indexOf(',');
        Integer userID = Integer.valueOf(line.substring(0, firstComma));
        int secondComma = line.indexOf(',', firstComma + 1);
        float rating = Float.parseFloat(line.substring(firstComma + 1, secondComma));
        prefs.add(new GenericPreference(userID, itemID, rating));
      }
    } catch (IOException ioe) {
      throw new TasteException(ioe);
    }
    return new GenericItemPreferenceArray(prefs);
View Full Code Here

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

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

        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

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

    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

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

  }

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

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

      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

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

        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

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

    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

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

        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

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

   * @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
TOP
Copyright © 2018 www.massapi.com. 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.