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

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


    return this.preferenceForItems;
  }
 
  @Override
  public LongPrimitiveArrayIterator getUserIDs() {
    return new LongPrimitiveArrayIterator(userIDs);
  }
View Full Code Here


    return itemIDs;
  }
 
  @Override
  public LongPrimitiveArrayIterator getItemIDs() {
    return new LongPrimitiveArrayIterator(itemIDs);
  }
View Full Code Here

  }

  @Override
  protected FastIDSet doGetCandidateItems(long[] preferredItemIDs, DataModel dataModel) throws TasteException {
    FastIDSet possibleItemsIDs = new FastIDSet();
    LongPrimitiveIterator preferredItemIDsIterator = new LongPrimitiveArrayIterator(preferredItemIDs);
    if (preferredItemIDs.length > maxItems) {
      double samplingRate = (double) maxItems / preferredItemIDs.length;
//      log.info("preferredItemIDs.length {}, samplingRate {}", preferredItemIDs.length, samplingRate);
      preferredItemIDsIterator =
          new SamplingLongPrimitiveIterator(preferredItemIDsIterator, samplingRate);
    }
    while (preferredItemIDsIterator.hasNext()) {
      long itemID = preferredItemIDsIterator.nextLong();
      PreferenceArray prefs = dataModel.getPreferencesForItem(itemID);
      int prefsLength = prefs.length();
      if (prefsLength > maxUsersPerItem) {
        Iterator<Preference> sampledPrefs =
            new FixedSizeSamplingIterator<Preference>(maxUsersPerItem, prefs.iterator());
View Full Code Here

  public void testTopItems() throws Exception {
    long[] ids = new long[100];
    for (int i = 0; i < 100; i++) {
      ids[i] = i;
    }
    LongPrimitiveIterator possibleItemIds = new LongPrimitiveArrayIterator(ids);
    TopItems.Estimator<Long> estimator = new TopItems.Estimator<Long>() {
      @Override
      public double estimate(Long thing) {
        return thing;
      }
View Full Code Here

  public void testTopItemsRandom() throws Exception {
    long[] ids = new long[100];
    for (int i = 0; i < 100; i++) {
      ids[i] = i;
    }
    LongPrimitiveIterator possibleItemIds = new LongPrimitiveArrayIterator(ids);
    final Random random = RandomUtils.getRandom();
    TopItems.Estimator<Long> estimator = new TopItems.Estimator<Long>() {
      @Override
      public double estimate(Long thing) {
        return random.nextDouble();
View Full Code Here

  public void testTopUsers() throws Exception {
    long[] ids = new long[100];
    for (int i = 0; i < 100; i++) {
      ids[i] = i;
    }
    LongPrimitiveIterator possibleItemIds = new LongPrimitiveArrayIterator(ids);
    TopItems.Estimator<Long> estimator = new TopItems.Estimator<Long>() {
      @Override
      public double estimate(Long thing) {
        return thing;
      }
View Full Code Here

  }

  @Override
  protected FastIDSet doGetCandidateItems(long[] preferredItemIDs, DataModel dataModel, boolean includeKnownItems)
    throws TasteException {
    LongPrimitiveIterator preferredItemIDsIterator = new LongPrimitiveArrayIterator(preferredItemIDs);
    if (preferredItemIDs.length > maxItems) {
      double samplingRate = (double) maxItems / preferredItemIDs.length;
//      log.info("preferredItemIDs.length {}, samplingRate {}", preferredItemIDs.length, samplingRate);
      preferredItemIDsIterator =
          new SamplingLongPrimitiveIterator(preferredItemIDsIterator, samplingRate);
    }
    FastIDSet possibleItemsIDs = new FastIDSet();
    while (preferredItemIDsIterator.hasNext()) {
      long itemID = preferredItemIDsIterator.nextLong();
      PreferenceArray prefs = dataModel.getPreferencesForItem(itemID);
      int prefsLength = prefs.length();
      if (prefsLength > maxUsersPerItem) {
        Iterator<Preference> sampledPrefs =
            new FixedSizeSamplingIterator<Preference>(maxUsersPerItem, prefs.iterator());
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.impl.common.LongPrimitiveArrayIterator

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.