Examples of FastIDSet


Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

   
    if (getNumPreferences(userID) == 0) {
      return Collections.emptyList();
    }
   
    FastIDSet possibleItemIDs = getAllOtherItems(userID);
   
    TopItems.Estimator<Long> estimator = new Estimator(userID);
   
    List<RecommendedItem> topItems = TopItems.getTopItems(howMany, possibleItemIDs.iterator(), rescorer,
      estimator);
   
    log.debug("Recommendations are: {}", topItems);
    return topItems;
  }
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

    DataModel model = getDataModel();
    TopItems.Estimator<Long> estimator = new RecommendedBecauseEstimator(userID, itemID, similarity);
   
    PreferenceArray prefs = model.getPreferencesFromUser(userID);
    int size = prefs.length();
    FastIDSet allUserItems = new FastIDSet(size);
    for (int i = 0; i < size; i++) {
      allUserItems.add(prefs.getItemID(i));
    }
    allUserItems.remove(itemID);
   
    return TopItems.getTopItems(howMany, allUserItems.iterator(), null, estimator);
  }
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

 
  private List<RecommendedItem> doMostSimilarItems(long[] itemIDs,
                                                   int howMany,
                                                   TopItems.Estimator<Long> estimator) throws TasteException {
    DataModel model = getDataModel();
    FastIDSet possibleItemsIDs = new FastIDSet();
    for (long itemID : itemIDs) {
      PreferenceArray prefs = model.getPreferencesForItem(itemID);
      int size = prefs.length();
      for (int i = 0; i < size; i++) {
        long userID = prefs.get(i).getUserID();
        possibleItemsIDs.addAll(model.getItemIDsFromUser(userID));
      }
    }
    possibleItemsIDs.removeAll(itemIDs);
    return TopItems.getTopItems(howMany, possibleItemsIDs.iterator(), null, estimator);
  }
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

   
    this.dataFile = dataFile.getAbsoluteFile();
    this.lastModified = dataFile.lastModified();
    this.maxEntries = maxEntries;
    this.averageDiffs = new FastByIDMap<FastByIDMap<RunningAverage>>();
    this.allRecommendableItemIDs = new FastIDSet();
    this.buildAverageDiffsLock = new ReentrantReadWriteLock();
  }
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

    if (transpose) {
      long tmp = userID;
      userID = itemID;
      itemID = tmp;
    }
    FastIDSet itemIDs = data.get(userID);
    if (itemIDs == null) {
      itemIDs = new FastIDSet(2);
      data.put(userID, itemIDs);
    }
    itemIDs.add(itemID);
  }
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

      fileDataModel = new FileDataModel(tempDataFile);
      String usersFilePathString = jobConf.get(USERS_FILE);
      if (usersFilePathString == null) {
        usersToRecommendFor = null;
      } else {
        usersToRecommendFor = new FastIDSet();
        Path usersFilePath = new Path(usersFilePathString).makeQualified(fs);
        FSDataInputStream in = fs.open(usersFilePath);
        for (String line : new FileLineIterable(in)) {
          usersToRecommendFor.add(Long.parseLong(line));
        }
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

      log.debug("Executing SQL query: {}", getAllUsersSQL);
      rs = stmt.executeQuery(getAllUsersSQL);
     
      boolean currentUserIDSet = false;
      long currentUserID = 0L; // value isn't used
      FastIDSet currentItemIDs = new FastIDSet(2);
      while (rs.next()) {
        long nextUserID = getLongColumn(rs, 1);
        if (currentUserIDSet && (currentUserID != nextUserID)) {
          if (!currentItemIDs.isEmpty()) {
            result.put(currentUserID, currentItemIDs);
            currentItemIDs = new FastIDSet(2);
          }
        } else {
          currentItemIDs.add(getLongColumn(rs, 2));
        }
        currentUserID = nextUserID;
        currentUserIDSet = true;
      }
      if (!currentItemIDs.isEmpty()) {
        result.put(currentUserID, currentItemIDs);
      }
     
      return result;
     
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

      setLongParameter(stmt, 1, id);
     
      log.debug("Executing SQL query: {}", getUserSQL);
      rs = stmt.executeQuery();
     
      FastIDSet result = new FastIDSet();
      while (rs.next()) {
        result.add(getLongColumn(rs, 2));
      }
     
      if (result.isEmpty()) {
        throw new NoSuchUserException();
      }
     
      return result;
     
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

      throw new IllegalArgumentException("howMany must be at least 1");
    }
   
    log.debug("Recommending items for user ID '{}'", userID);
   
    FastIDSet possibleItemIDs = getAllOtherItems(userID);
   
    TopItems.Estimator<Long> estimator = new Estimator(userID);
   
    List<RecommendedItem> topItems = TopItems.getTopItems(howMany, possibleItemIDs.iterator(), rescorer,
      estimator);
   
    log.debug("Recommendations are: {}", topItems);
    return topItems;
  }
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

  }
 
  @Override
  public FastIDSet getCluster(long userID) throws TasteException {
    buildClusters();
    FastIDSet cluster = clustersByUserID.get(userID);
    return cluster == null ? new FastIDSet() : cluster;
  }
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.