Examples of LongPair


Examples of bgu.bio.adt.tuples.LongPair

  private double calculateCategory(String categoryName, String... features) {
    TLongArrayList denomList = new TLongArrayList();
    TLongArrayList numList = new TLongArrayList();

    LongPair pair = new LongPair();
    /*
     * categoryProbability(categoryName, pair); gcd(pair);
     * denomList.add(pair.getSecond()); numList.add(pair.getFirst());
     */
    Category category = categories.get(categoryName);
    for (int i = 0; i < features.length; i++) {
      pair.setFirst(category.featureOccurences(features[i]) + alpha);
      pair.setSecond(featureOccurences(features[i]) + categories.size()
          * alpha);
      gcd(pair);
      numList.add(pair.getFirst());
      denomList.add(pair.getSecond());
    }
    // count the amount of zeros in the lists

    long numerator = 1, denominator = 1;
    for (int i = 0; i < denomList.size(); i++) {
View Full Code Here

Examples of org.apache.mahout.common.LongPair

    this.similarityCache = new Cache<LongPair,Double>(new SimilarityRetriever(similarity), maxCacheSize);
  }
 
  @Override
  public double itemSimilarity(long itemID1, long itemID2) throws TasteException {
    LongPair key = itemID1 < itemID2 ? new LongPair(itemID1, itemID2) : new LongPair(itemID2, itemID1);
    return similarityCache.get(key);
  }
View Full Code Here

Examples of org.apache.mahout.common.LongPair

    this.similarityCache = new Cache<LongPair,Double>(new SimilarityRetriever(similarity), maxCacheSize);
  }
 
  @Override
  public double userSimilarity(long userID1, long userID2) throws TasteException {
    LongPair key = userID1 < userID2 ? new LongPair(userID1, userID2) : new LongPair(userID2, userID1);
    return similarityCache.get(key);
  }
View Full Code Here

Examples of org.apache.mahout.common.LongPair

        return Double.NaN;
      }
      if (rescorer == null) {
        return similarity.userSimilarity(toUserID, userID);
      } else {
        LongPair pair = new LongPair(toUserID, userID);
        if (rescorer.isFiltered(pair)) {
          return Double.NaN;
        }
        double originalEstimate = similarity.userSimilarity(toUserID, userID);
        return rescorer.rescore(pair, originalEstimate);
View Full Code Here

Examples of org.apache.mahout.common.LongPair

    return recommendedItems.size() > howMany ? recommendedItems.subList(0, howMany) : recommendedItems;
  }
 
  @Override
  public float estimatePreference(long userID, long itemID) throws TasteException {
    return estimatedPrefCache.get(new LongPair(userID, itemID));
  }
View Full Code Here

Examples of org.apache.mahout.common.LongPair

      this.rescorer = rescorer;
    }
   
    @Override
    public double estimate(Long itemID) throws TasteException {
      LongPair pair = new LongPair(toItemID, itemID);
      if ((rescorer != null) && rescorer.isFiltered(pair)) {
        return Double.NaN;
      }
      double originalEstimate = similarity.itemSimilarity(toItemID, itemID);
      return rescorer == null ? originalEstimate : rescorer.rescore(pair, originalEstimate);
View Full Code Here

Examples of org.apache.mahout.common.LongPair

   
    @Override
    public double estimate(Long itemID) throws TasteException {
      RunningAverage average = new FullRunningAverage();
      for (long toItemID : toItemIDs) {
        LongPair pair = new LongPair(toItemID, itemID);
        if ((rescorer != null) && rescorer.isFiltered(pair)) {
          continue;
        }
        double estimate = similarity.itemSimilarity(toItemID, itemID);
        if (rescorer != null) {
View Full Code Here

Examples of org.apache.mahout.common.LongPair

        return Double.NaN;
      }
      if (rescorer == null) {
        return similarity.userSimilarity(toUserID, userID);
      } else {
        LongPair pair = new LongPair(toUserID, userID);
        if (rescorer.isFiltered(pair)) {
          return Double.NaN;
        }
        double originalEstimate = similarity.userSimilarity(toUserID, userID);
        return rescorer.rescore(pair, originalEstimate);
View Full Code Here

Examples of org.apache.mahout.common.LongPair

      this.rescorer = rescorer;
    }
   
    @Override
    public double estimate(Long itemID) throws TasteException {
      LongPair pair = new LongPair(toItemID, itemID);
      if ((rescorer != null) && rescorer.isFiltered(pair)) {
        return Double.NaN;
      }
      double originalEstimate = similarity.itemSimilarity(toItemID, itemID);
      return rescorer == null ? originalEstimate : rescorer.rescore(pair, originalEstimate);
View Full Code Here

Examples of org.apache.mahout.common.LongPair

    public double estimate(Long itemID) throws TasteException {
      RunningAverage average = new FullRunningAverage();
      double[] similarities = similarity.itemSimilarities(itemID, toItemIDs);
      for (int i = 0; i < toItemIDs.length; i++) {
        long toItemID = toItemIDs[i];
        LongPair pair = new LongPair(toItemID, itemID);
        if ((rescorer != null) && rescorer.isFiltered(pair)) {
          continue;
        }
        double estimate = similarities[i];
        if (rescorer != null) {
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.