Package net.myrrix.common.stats

Examples of net.myrrix.common.stats.DoubleWeightedMean


  @Override
  public EvaluationResult evaluate(MyrrixRecommender recommender,
                                   RescorerProvider provider, // ignored
                                   Multimap<Long,RecommendedItem> testData) throws TasteException {
    DoubleWeightedMean score = new DoubleWeightedMean();
    int count = 0;
    for (Map.Entry<Long,RecommendedItem> entry : testData.entries()) {
      long userID = entry.getKey();
      RecommendedItem itemPref = entry.getValue();
      try {
        float estimate = recommender.estimatePreference(userID, itemPref.getItemID());
        Preconditions.checkState(LangUtils.isFinite(estimate));
        score.increment(1.0 - estimate, itemPref.getValue());
      } catch (NoSuchItemException nsie) {
        // continue
      } catch (NoSuchUserException nsue) {
        // continue
      }
      if (++count % 100000 == 0) {
        log.info("Score: {}", score);
      }
    }
    log.info("Score: {}", score);
    return new EvaluationResultImpl(score.getResult());
  }
View Full Code Here


    try {
      int iterationNumber = 0;
      while (true) {
        iterateXFromY(executor);
        iterateYFromX(executor);
        DoubleWeightedMean averageAbsoluteEstimateDiff = new DoubleWeightedMean();
        for (int i = 0; i < testUserIDs.length; i++) {
          for (int j = 0; j < testItemIDs.length; j++) {
            double newValue = SimpleVectorMath.dot(X.get(testUserIDs[i]), Y.get(testItemIDs[j]));           
            double oldValue = estimates[i][j];
            estimates[i][j] = newValue;
            averageAbsoluteEstimateDiff.increment(FastMath.abs(newValue - oldValue), FastMath.max(0.0, newValue));
          }
        }
     
        iterationNumber++;
        log.info("Finished iteration {}", iterationNumber);
        if (maxIterations > 0 && iterationNumber >= maxIterations) {
          log.info("Reached iteration limit");
          break;
        }
        log.info("Avg absolute difference in estimate vs prior iteration: {}", averageAbsoluteEstimateDiff);
        double convergenceValue = averageAbsoluteEstimateDiff.getResult();
        if (!LangUtils.isFinite(convergenceValue)) {
          log.warn("Invalid convergence value, aborting iteration! {}", convergenceValue);
          break;
        }
        // Don't converge after 1 iteration if starting from a random point
View Full Code Here

TOP

Related Classes of net.myrrix.common.stats.DoubleWeightedMean

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.