Package org.apache.mahout.cf.taste.similarity.precompute

Examples of org.apache.mahout.cf.taste.similarity.precompute.SimilarItem


      int itemIDIndex = itemIDIndexWritable.get();

      TopSimilarItemsQueue topKMostSimilarItems = new TopSimilarItemsQueue(maxSimilarItemsPerItem);

      for (Vector.Element element : similarityVector.get().nonZeroes()) {
        SimilarItem top = topKMostSimilarItems.top();
        double candidateSimilarity = element.get();
        if (candidateSimilarity > top.getSimilarity()) {
          top.set(indexItemIDMap.get(element.index()), candidateSimilarity);
          topKMostSimilarItems.updateTop();
        }
      }

      long itemID = indexItemIDMap.get(itemIDIndex);
View Full Code Here


  }

  public List<SimilarItem> getTopItems() {
    List<SimilarItem> items = Lists.newArrayListWithCapacity(maxSize);
    while (size() > 0) {
      SimilarItem topItem = pop();
      // filter out "sentinel" objects necessary for maintaining an efficient priority queue
      if (topItem.getItemID() != SENTINEL_ID) {
        items.add(topItem);
      }
    }
    Collections.reverse(items);
    return items;
View Full Code Here

    return one.getSimilarity() < two.getSimilarity();
  }

  @Override
  protected SimilarItem getSentinelObject() {
    return new SimilarItem(SENTINEL_ID, Double.MIN_VALUE);
  }
View Full Code Here

      int itemIDIndex = itemIDIndexWritable.get();

      TopSimilarItemsQueue topKMostSimilarItems = new TopSimilarItemsQueue(maxSimilarItemsPerItem);

      for (Vector.Element element : similarityVector.get().nonZeroes()) {
        SimilarItem top = topKMostSimilarItems.top();
        double candidateSimilarity = element.get();
        if (candidateSimilarity > top.getSimilarity()) {
          top.set(indexItemIDMap.get(element.index()), candidateSimilarity);
          topKMostSimilarItems.updateTop();
        }
      }

      long itemID = indexItemIDMap.get(itemIDIndex);
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.similarity.precompute.SimilarItem

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.