Package org.apache.mahout.cf.taste.recommender

Examples of org.apache.mahout.cf.taste.recommender.IDRescorer


  }

  @Override
  public List<RecommendedItem> recommend(long userID, int howMany)
      throws TasteException {
    IDRescorer rescorer = new GenderRescorer(
        men, women, usersRateMoreMen, usersRateLessMen, userID, model);
    return delegate.recommend(userID, howMany, rescorer);
  }
View Full Code Here


  }

  @Override
  public float estimatePreference(long userID, long itemID)
      throws TasteException {
    IDRescorer rescorer = new GenderRescorer(
        men, women, usersRateMoreMen, usersRateLessMen, userID, model);
    return (float) rescorer.rescore(
        itemID, delegate.estimatePreference(userID, itemID));
  }
View Full Code Here

    assertEquals(4, recommendCount.get());
    cachingRecommender.recommend(3, 1);
    assertEquals(5, recommendCount.get());

    // Results from this recommend() method can be cached...
    IDRescorer rescorer = NullRescorer.getItemInstance();
    cachingRecommender.refresh(null);
    cachingRecommender.recommend(1, 1, rescorer);
    assertEquals(6, recommendCount.get());
    cachingRecommender.recommend(2, 1, rescorer);
    assertEquals(7, recommendCount.get());
View Full Code Here

/** <p>Tests {@link NullRescorer}.</p> */
public final class NullRescorerTest extends TasteTestCase {

  public void testItemRescorer() throws Exception {
    IDRescorer rescorer = NullRescorer.getItemInstance();
    assertNotNull(rescorer);
    assertEquals(1.0, rescorer.rescore(1L, 1.0));
    assertEquals(1.0, rescorer.rescore(0L, 1.0));
    assertEquals(0.0, rescorer.rescore(1L, 0.0));
    assertTrue(Double.isNaN(rescorer.rescore(1L, Double.NaN)));
  }
View Full Code Here

    assertEquals(0.0, rescorer.rescore(1L, 0.0));
    assertTrue(Double.isNaN(rescorer.rescore(1L, Double.NaN)));
  }

  public void testUserRescorer() throws Exception {
    IDRescorer rescorer = NullRescorer.getUserInstance();
    assertNotNull(rescorer);
    assertEquals(1.0, rescorer.rescore(1L, 1.0));
    assertEquals(1.0, rescorer.rescore(0L, 1.0));
    assertEquals(0.0, rescorer.rescore(1L, 0.0));
    assertTrue(Double.isNaN(rescorer.rescore(1L, Double.NaN)));
  }
View Full Code Here

   
    @Override
    public Recommendations get(Long key) throws TasteException {
      log.debug("Retrieving new recommendations for user ID '{}'", key);
      int howMany = maxHowMany[0];
      IDRescorer rescorer = getCurrentRescorer();
      List<RecommendedItem> recommendations = rescorer == null ? recommender.recommend(key, howMany)
          : recommender.recommend(key, howMany, rescorer);
      return new Recommendations(Collections.unmodifiableList(recommendations));
    }
View Full Code Here

   
    @Override
    public Recommendations get(Long key) throws TasteException {
      log.debug("Retrieving new recommendations for user ID '{}'", key);
      int howMany = maxHowMany[0];
      IDRescorer rescorer = getCurrentRescorer();
      List<RecommendedItem> recommendations = rescorer == null ? recommender.recommend(key, howMany)
          : recommender.recommend(key, howMany, rescorer);
      return new Recommendations(Collections.unmodifiableList(recommendations));
    }
View Full Code Here

    assertEquals(4, recommendCount.intValue());
    cachingRecommender.recommend(3, 1);
    assertEquals(5, recommendCount.intValue());

    // Results from this recommend() method can be cached...
    IDRescorer rescorer = NullRescorer.getItemInstance();
    cachingRecommender.refresh(null);
    cachingRecommender.recommend(1, 1, rescorer);
    assertEquals(6, recommendCount.intValue());
    cachingRecommender.recommend(2, 1, rescorer);
    assertEquals(7, recommendCount.intValue());
View Full Code Here

    assertEquals(4, recommendCount.intValue());
    cachingRecommender.recommend(3, 1);
    assertEquals(5, recommendCount.intValue());

    // Results from this recommend() method can be cached...
    IDRescorer rescorer = NullRescorer.getItemInstance();
    cachingRecommender.refresh(null);
    cachingRecommender.recommend(1, 1, rescorer);
    assertEquals(6, recommendCount.intValue());
    cachingRecommender.recommend(2, 1, rescorer);
    assertEquals(7, recommendCount.intValue());
View Full Code Here

  private final class RecommendationRetriever implements Retriever<Long,Recommendations> {
    @Override
    public Recommendations get(Long key) throws TasteException {
      log.debug("Retrieving new recommendations for user ID '{}'", key);
      int howMany = maxHowMany[0];
      IDRescorer rescorer = currentRescorer;
      List<RecommendedItem> recommendations =
          rescorer == null ? recommender.recommend(key, howMany) : recommender.recommend(key, howMany, rescorer);
      return new Recommendations(Collections.unmodifiableList(recommendations));
    }
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.recommender.IDRescorer

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.