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

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


        int numValues = values.size();
        if (numValues == 0) {
          return;
        }
       
        IDRescorer rescorer =
            provider == null ? null : provider.getRecommendRescorer(new long[]{userID}, recommender);
 
        List<RecommendedItem> recs;
        try {
          recs = recommender.recommend(userID, numValues, rescorer);
View Full Code Here


public final class FilterHalfRescorerProvider extends AbstractRescorerProvider {

  @Override
  public IDRescorer getRecommendRescorer(final long[] userIDs, MyrrixRecommender recommender, String... args) {
    final boolean odd = args.length > 0 && "odd".equalsIgnoreCase(args[0]);
    return new IDRescorer() {
      @Override
      public double rescore(long itemID, double score) {
        for (long userID : userIDs) {
          if (odd == ((userID & 0x01) == 1)) {
            return Double.NaN;
View Full Code Here

  @Override
  public IDRescorer getRecommendToAnonymousRescorer(final long[] itemIDs,
                                                    MyrrixRecommender recommender,
                                                    String... args) {
    final boolean odd = args.length > 0 && "odd".equalsIgnoreCase(args[0]);
    return new IDRescorer() {
      @Override
      public double rescore(long itemID, double score) {
        for (long anItemID : itemIDs) {
          if (odd == ((anItemID & 0x01) == 1)) {
            return Double.NaN;
View Full Code Here

  }

  @Override
  public IDRescorer getMostPopularItemsRescorer(MyrrixRecommender recommender, String... args) {
    final boolean odd = args.length > 0 && "odd".equalsIgnoreCase(args[0]);
    return new IDRescorer() {
      @Override
      public double rescore(long itemID, double score) {
        return isFiltered(itemID) ? Double.NaN : 10.0 * score;
      }
      @Override
View Full Code Here

                  itemTags.put(userIDString, new GenericRecommendedItem(itemID, value));
                } else if (itemIsTag) {
                  userTags.put(itemIDString, new GenericRecommendedItem(userID, value));
                } else {
                  if (provider != null) {
                    IDRescorer rescorer = provider.getRecommendRescorer(new long[] {userID}, null);
                    if (rescorer != null) {
                      value = (float) rescorer.rescore(itemID, value);
                    }
                  }
                  data.put(userID, new GenericRecommendedItem(itemID, value));
                }
              }
              // Ignore remove lines
            } else {
              if (userIsTag) {
                itemTags.put(userIDString, new GenericRecommendedItem(itemID, 1.0f));
              } else if (itemIsTag) {
                userTags.put(itemIDString, new GenericRecommendedItem(userID, 1.0f));
              } else {
                float value = 1.0f;               
                if (provider != null) {
                  IDRescorer rescorer = provider.getRecommendRescorer(new long[] {userID}, null);
                  if (rescorer != null) {
                    value = (float) rescorer.rescore(itemID, value);
                  }
                }
                data.put(userID, new GenericRecommendedItem(itemID, value));
              }
            }
View Full Code Here

    final Writer out = new OutputStreamWriter(new FileOutputStream(outFile), Charsets.UTF_8);
   
    Processor<Long> processor = new Processor<Long>() {
      @Override
      public void process(Long userID, long count) throws ExecutionException {
        IDRescorer rescorer =
            rescorerProvider == null ? null : rescorerProvider.getRecommendRescorer(new long[]{userID}, recommender);
        Iterable<RecommendedItem> recs;
        try {
          recs = recommender.recommend(userID, howMany, rescorer);
        } catch (TasteException te) {
View Full Code Here

    }

    MyrrixRecommender recommender = getRecommender();
    RescorerProvider rescorerProvider = getRescorerProvider();
    try {
      IDRescorer rescorer = rescorerProvider == null ? null :
          rescorerProvider.getRecommendRescorer(new long[] {userID}, recommender, getRescorerParams(request));
      Iterable<RecommendedItem> recommended =
          recommender.recommend(userID, getHowMany(request), getConsiderKnownItems(request), rescorer);
      output(request, response, recommended);
    } catch (NoSuchUserException nsue) {
View Full Code Here

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    MyrrixRecommender recommender = getRecommender();
    RescorerProvider rescorerProvider = getRescorerProvider();
    try {
      IDRescorer rescorer = rescorerProvider == null ? null :
          rescorerProvider.getMostPopularItemsRescorer(recommender, getRescorerParams(request));
      output(request, response, recommender.mostPopularItems(getHowMany(request), rescorer));
    } catch (NotReadyException nre) {
      response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString());
    } catch (TasteException te) {
View Full Code Here

    long[] userIDs = userIDSet.toArray();

    MyrrixRecommender recommender = getRecommender();
    RescorerProvider rescorerProvider = getRescorerProvider();
    try {
      IDRescorer rescorer = rescorerProvider == null ? null :
          rescorerProvider.getRecommendRescorer(userIDs, recommender, getRescorerParams(request));
      Iterable<RecommendedItem> recommended =
          recommender.recommendToMany(userIDs, getHowMany(request), getConsiderKnownItems(request), rescorer);
      output(request, response, recommended);
    } catch (NoSuchUserException nsue) {
View Full Code Here

    float[] values = itemIDsAndValue.getSecond();
   
    MyrrixRecommender recommender = getRecommender();
    RescorerProvider rescorerProvider = getRescorerProvider();
    try {
      IDRescorer rescorer = rescorerProvider == null ? null :
          rescorerProvider.getRecommendToAnonymousRescorer(itemIDs, recommender, getRescorerParams(request));
      Iterable<RecommendedItem> recommended =
          recommender.recommendToAnonymous(itemIDs, values, getHowMany(request), rescorer);
      output(request, response, recommended);
    } catch (NotReadyException nre) {
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.