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

The following examples show how to use org.apache.mahout.cf.taste.recommender.IDRescorer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MostPopularItemsServlet.java    From myrrix-recommender with Apache License 2.0 6 votes vote down vote up
@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) {
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.toString());
    getServletContext().log("Unexpected error in " + getClass().getSimpleName(), te);
  } catch (IllegalArgumentException iae) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, iae.toString());
  }
}
 
Example #2
Source File: MostPopularItemsIterator.java    From myrrix-recommender with Apache License 2.0 6 votes vote down vote up
@Override
public RecommendedItem next() {
  FastByIDFloatMap.MapEntry entry = countsIterator.next();
  long id = entry.getKey();
  float value = entry.getValue();
  IDRescorer theRescorer = rescorer;
  if (theRescorer != null) {
    if (theRescorer.isFiltered(id)) {
      return null;
    }
    value = (float) theRescorer.rescore(id, value);
    if (!LangUtils.isFinite(value)) {
      return null;
    }
  }
  delegate.set(id, value);
  return delegate;
}
 
Example #3
Source File: MultiRescorerProviderTest.java    From myrrix-recommender with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultiRecommendRescorer() {
  RescorerProvider multi = 
      new MultiRescorerProvider(new SimpleModRescorerProvider(2), new SimpleModRescorerProvider(3));
  
  IDRescorer provider = multi.getRecommendRescorer(new long[]{5}, (MyrrixRecommender) null);
  assertNull(provider);
  
  provider = multi.getRecommendRescorer(new long[]{2}, (MyrrixRecommender) null);
  assertNotNull(provider);
  assertFalse(provider instanceof MultiRescorer);
  assertTrue(provider.isFiltered(3));
  assertFalse(provider.isFiltered(2));

  provider = multi.getRecommendRescorer(new long[]{6}, (MyrrixRecommender) null);
  assertNotNull(provider);
  assertTrue(provider instanceof MultiRescorer);
  assertTrue(provider.isFiltered(3));
  assertTrue(provider.isFiltered(2));
  assertFalse(provider.isFiltered(12));
}
 
Example #4
Source File: MultiRescorerProviderTest.java    From myrrix-recommender with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultiRecommendToAnonymousRescorer() {
  RescorerProvider multi = 
      new MultiRescorerProvider(new SimpleModRescorerProvider(2), new SimpleModRescorerProvider(3));
  
  IDRescorer provider = multi.getRecommendToAnonymousRescorer(new long[]{5}, (MyrrixRecommender) null);
  assertNull(provider);
  
  provider = multi.getRecommendToAnonymousRescorer(new long[]{2}, (MyrrixRecommender) null);
  assertNotNull(provider);
  assertFalse(provider instanceof MultiRescorer);
  assertTrue(provider.isFiltered(3));
  assertFalse(provider.isFiltered(2));

  provider = multi.getRecommendToAnonymousRescorer(new long[]{6}, (MyrrixRecommender) null);
  assertNotNull(provider);
  assertTrue(provider instanceof MultiRescorer);
  assertTrue(provider.isFiltered(3));
  assertTrue(provider.isFiltered(2));
  assertFalse(provider.isFiltered(12));
}
 
Example #5
Source File: MultiRescorerProviderTest.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiMostPopularItemsRescorer() {
  RescorerProvider multi = 
      new MultiRescorerProvider(new SimpleModRescorerProvider(2), new SimpleModRescorerProvider(3));
  IDRescorer provider = multi.getMostPopularItemsRescorer(null);
  assertNotNull(provider);
  assertTrue(provider instanceof MultiRescorer);
  assertTrue(provider.isFiltered(3));
  assertTrue(provider.isFiltered(2));
  assertFalse(provider.isFiltered(6));    
}
 
Example #6
Source File: MultiRescorer.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
@Override
public double rescore(long itemID, double value) {
  for (IDRescorer rescorer : rescorers) {
    value = rescorer.rescore(itemID, value);
    if (Double.isNaN(value)) {
      return Double.NaN;
    }
  }
  return value;
}
 
Example #7
Source File: MultiRescorer.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isFiltered(long itemID) {
  for (IDRescorer rescorer : rescorers) {
    if (rescorer.isFiltered(itemID)) {
      return true;
    }
  }
  return false;
}
 
Example #8
Source File: MultiRescorerProvider.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
@Override
public IDRescorer getRecommendRescorer(long[] userIDs, MyrrixRecommender recommender, String... args) {
  List<IDRescorer> rescorers = Lists.newArrayListWithCapacity(providers.length);
  for (RescorerProvider provider : providers) {
    IDRescorer rescorer = provider.getRecommendRescorer(userIDs, recommender, args);
    if (rescorer != null) {
      rescorers.add(rescorer);
    }
  }
  return buildRescorer(rescorers);
}
 
Example #9
Source File: MultiRescorerProvider.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
@Override
public IDRescorer getRecommendToAnonymousRescorer(long[] itemIDs, MyrrixRecommender recommender, String... args) {
  List<IDRescorer> rescorers = Lists.newArrayListWithCapacity(providers.length);
  for (RescorerProvider provider : providers) {
    IDRescorer rescorer = provider.getRecommendToAnonymousRescorer(itemIDs, recommender, args);
    if (rescorer != null) {
      rescorers.add(rescorer);
    }
  }
  return buildRescorer(rescorers);  
}
 
Example #10
Source File: MultiRescorerProvider.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
@Override
public IDRescorer getMostPopularItemsRescorer(MyrrixRecommender recommender, String... args) {
  List<IDRescorer> rescorers = Lists.newArrayListWithCapacity(providers.length);
  for (RescorerProvider provider : providers) {
    IDRescorer rescorer = provider.getMostPopularItemsRescorer(recommender, args);
    if (rescorer != null) {
      rescorers.add(rescorer);
    }
  }
  return buildRescorer(rescorers); 
}
 
Example #11
Source File: MultiRescorerProvider.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
private static IDRescorer buildRescorer(List<IDRescorer> rescorers) {
  int numRescorers = rescorers.size();
  if (numRescorers == 0) {
    return null;
  }
  if (numRescorers == 1) {
    return rescorers.get(0);
  }
  return new MultiRescorer(rescorers);
}
 
Example #12
Source File: BookRecommender.java    From Machine-Learning-in-Java with MIT License 5 votes vote down vote up
public static ItemBasedRecommender itemBased() throws Exception {

		// Load the data
		StringItemIdFileDataModel dataModel = loadFromFile("data/BX-Book-Ratings.csv", ";");
		// Collection<GenericItemSimilarity.ItemItemSimilarity> correlations =
		// null;
		// ItemItemSimilarity iis = new ItemItemSimilarity(0, 0, 0);
		// ItemSimilarity itemSimilarity = new
		// GenericItemSimilarity(correlations);
		ItemSimilarity itemSimilarity = new PearsonCorrelationSimilarity(dataModel);

		ItemBasedRecommender recommender = new GenericItemBasedRecommender(
				dataModel, itemSimilarity);

		IDRescorer rescorer = new MyRescorer();

		// List recommendations = recommender.recommend(2, 3, rescorer);
		String itemISBN = "042513976X";
		long itemID = dataModel.readItemIDFromString(itemISBN);
		int noItems = 10;

		System.out.println("Recommendations for item: " + books.get(itemISBN));

		System.out.println("\nMost similar items:");
		List<RecommendedItem> recommendations = recommender.mostSimilarItems(
				itemID, noItems);
		for (RecommendedItem item : recommendations) {
			itemISBN = dataModel.getItemIDAsString(item.getItemID());
			System.out.println("Item: " + books.get(itemISBN) + " | Item id: "
					+ itemISBN + " | Value: " + item.getValue());
		}
		
		return recommender;
	}
 
Example #13
Source File: ClientRecommender.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
/**
 * {@link Rescorer}s are not available at this time in the model.
 *
 * @return {@link #recommend(long, int)} if rescorer is null
 * @throws UnsupportedOperationException otherwise
 * @deprecated use {@link #recommend(long, int)} instead
 */
@Deprecated
@Override
public List<RecommendedItem> recommend(long userID, int howMany, IDRescorer rescorer)
    throws TasteException {
  if (rescorer != null) {
    throw new UnsupportedOperationException();
  }
  return recommend(userID, howMany);
}
 
Example #14
Source File: ClientRecommender.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
/**
 * {@link Rescorer}s are not available at this time in the model.
 *
 * @return {@link #recommend(long, int, boolean, String[])} if rescorer is null
 * @throws UnsupportedOperationException otherwise
 * @deprecated use {@link #recommend(long, int, boolean, String[])} instead
 */
@Deprecated
@Override
public List<RecommendedItem> recommend(long userID,
                                       int howMany,
                                       boolean considerKnownItems,
                                       IDRescorer rescorer) throws TasteException {
  if (rescorer != null) {
    throw new UnsupportedOperationException();
  }
  return recommend(userID, howMany, considerKnownItems, (String[]) null);
}
 
Example #15
Source File: ClientRecommender.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
@Deprecated
@Override
public List<RecommendedItem> recommendToMany(long[] userIDs,
                                             int howMany,
                                             boolean considerKnownItems,
                                             IDRescorer rescorer) throws TasteException {
  if (rescorer != null) {
    throw new UnsupportedOperationException();
  }
  return recommendToMany(userIDs, howMany, considerKnownItems, (String[]) null);
}
 
Example #16
Source File: ClientRecommender.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
/**
 * Note that {@link IDRescorer} is not supported in the client now and must be null.
 *
 * @return {@link #recommendToAnonymous(long[], int)} if rescorer is null
 * @throws UnsupportedOperationException otherwise
 * @deprecated use {@link #recommendToAnonymous(long[], int)} instead
 */
@Deprecated
@Override
public List<RecommendedItem> recommendToAnonymous(long[] itemIDs,
                                                  int howMany,
                                                  IDRescorer rescorer) throws TasteException {
  if (rescorer != null) {
    throw new UnsupportedOperationException();
  }
  return recommendToAnonymous(itemIDs, howMany);
}
 
Example #17
Source File: ClientRecommender.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
/**
 * Note that {@link IDRescorer} is not supported in the client now and must be null.
 *
 * @return {@link #recommendToAnonymous(long[], float[], int)} if rescorer is null
 * @throws UnsupportedOperationException otherwise
 * @deprecated use {@link #recommendToAnonymous(long[], float[], int)} instead
 */
@Deprecated
@Override
public List<RecommendedItem> recommendToAnonymous(long[] itemIDs,
                                                  float[] values,
                                                  int howMany,
                                                  IDRescorer rescorer) throws TasteException {
  if (rescorer != null) {
    throw new UnsupportedOperationException();
  }
  return recommendToAnonymous(itemIDs, values, howMany);
}
 
Example #18
Source File: ClientRecommender.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
/**
 * Note that {@link IDRescorer} is not supported in the client now and must be null.
 *
 * @return {@link #mostPopularItems(int)} if rescorer is null
 * @throws UnsupportedOperationException otherwise
 * @deprecated use {@link #mostPopularItems(int)} instead
 */
@Deprecated
@Override
public List<RecommendedItem> mostPopularItems(int howMany, IDRescorer rescorer) throws TasteException {
  if (rescorer != null) {
    throw new UnsupportedOperationException();
  }
  return mostPopularItems(howMany);
}
 
Example #19
Source File: SimilarToItemRescorerProvider.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
@Override
public IDRescorer getRecommendRescorer(long[] userIDs, MyrrixRecommender recommender, String... args) {
  if (args == null || args.length == 0) {
    return null;
  }
  long toItemID = Long.parseLong(args[0]);
  return new SimilarToItemRescorer(toItemID, recommender);
}
 
Example #20
Source File: RecommendIterator.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
RecommendIterator(float[][] features,
                  Iterator<FastByIDMap.MapEntry<float[]>> Yiterator,
                  FastIDSet knownItemIDs,
                  FastIDSet userTagIDs,
                  IDRescorer rescorer) {
  Preconditions.checkArgument(features.length > 0, "features must not be empty");
  delegate = new MutableRecommendedItem();
  this.features = features;
  this.Yiterator = Yiterator;
  this.knownItemIDs = knownItemIDs;
  this.userTagIDs = userTagIDs;
  this.rescorer = rescorer;
}
 
Example #21
Source File: ServerRecommender.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
@Override
public List<RecommendedItem> recommendToAnonymous(long[] itemIDs,
                                                  float[] values,
                                                  int howMany,
                                                  IDRescorer rescorer)
    throws NotReadyException, NoSuchItemException {

  Preconditions.checkArgument(howMany > 0, "howMany must be positive");

  float[] anonymousUserFeatures = buildAnonymousUserFeatures(itemIDs, values);

  FastIDSet userKnownItemIDs = new FastIDSet(itemIDs.length);
  for (long itemID : itemIDs) {
    userKnownItemIDs.add(itemID);
  }

  float[][] anonymousFeaturesAsArray = { anonymousUserFeatures };

  Generation generation = getCurrentGeneration();    
  Lock yLock = generation.getYLock().readLock();    
  yLock.lock();
  try {
    return multithreadedTopN(anonymousFeaturesAsArray,
                             userKnownItemIDs,
                             generation.getUserTagIDs(),
                             rescorer,
                             howMany,
                             generation.getCandidateFilter());
  } finally {
    yLock.unlock();
  }
}
 
Example #22
Source File: RecommendIterator.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
@Override
public RecommendedItem next() {
  FastByIDMap.MapEntry<float[]> entry = Yiterator.next();
  long itemID = entry.getKey();
  
  if (userTagIDs.contains(itemID)) {
    return null;
  }
  
  FastIDSet theKnownItemIDs = knownItemIDs;
  if (theKnownItemIDs != null) {
    synchronized (theKnownItemIDs) {
      if (theKnownItemIDs.contains(itemID)) {
        return null;
      }
    }
  }

  IDRescorer rescorer = this.rescorer;
  if (rescorer != null && rescorer.isFiltered(itemID)) {
    return null;
  }

  float[] itemFeatures = entry.getValue();
  double sum = 0.0;
  int count = 0;
  for (float[] oneUserFeatures : features) {
    sum += SimpleVectorMath.dot(itemFeatures, oneUserFeatures);
    count++;
  }
  
  if (rescorer != null) {
    sum = rescorer.rescore(itemID, sum);
    if (!LangUtils.isFinite(sum)) {
      return null;
    }
  }

  float result = (float) (sum / count);
  Preconditions.checkState(LangUtils.isFinite(result), "Bad recommendation value");
  delegate.set(itemID, result);
  return delegate;
}
 
Example #23
Source File: SimilarToItemRescorerProvider.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
@Override
public IDRescorer getRecommendToAnonymousRescorer(long[] itemIDs, MyrrixRecommender recommender, String... args) {
  return getRecommendRescorer(null, recommender, args);
}
 
Example #24
Source File: AbstractRescorerProvider.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
/**
 * @return {@code null}
 */
@Override
public IDRescorer getRecommendRescorer(long[] userIDs, MyrrixRecommender recommender, String... args) {
  return null;
}
 
Example #25
Source File: AbstractRescorerProvider.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
/**
 * @return {@code null}
 */
@Override
public IDRescorer getRecommendToAnonymousRescorer(long[] itemIDs, MyrrixRecommender recommender, String... args) {
  return null;
}
 
Example #26
Source File: AbstractRescorerProvider.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
/**
 * @return {@code null}
 */
@Override
public IDRescorer getMostPopularItemsRescorer(MyrrixRecommender recommender, String... args) {
  return null;
}
 
Example #27
Source File: AllRecommendations.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
@Override
public Object call() throws IOException, InterruptedException, NotReadyException, ExecutionException {

  final ServerRecommender recommender = new ServerRecommender(config.getLocalInputDir());
  recommender.await();

  final RescorerProvider rescorerProvider = config.getRescorerProvider();
  final int howMany = config.getHowMany();
  
  File outFile = config.getOutFile();
  outFile.delete();
  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) {
        throw new ExecutionException(te);
      }
      String outLine = AllItemSimilarities.formatOutLine(userID, recs);
      synchronized (out) {
        try {
          out.write(outLine);
        } catch (IOException e) {
          throw new ExecutionException(e);
        }
      }
    }
  };

  Paralleler<Long> paralleler = 
      new Paralleler<Long>(recommender.getAllUserIDs().iterator(), processor, "AllRecommendations");
  if (config.isParallel()) {
    paralleler.runInParallel();
  } else {
    paralleler.runInSerial();
  }

  out.close();
  return null;
}
 
Example #28
Source File: RecommendServlet.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

  CharSequence pathInfo = request.getPathInfo();
  if (pathInfo == null) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path");
    return;
  }
  Iterator<String> pathComponents = SLASH.split(pathInfo).iterator();
  long userID;
  try {
    userID = Long.parseLong(pathComponents.next());
  } catch (NoSuchElementException nsee) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString());
    return;
  } catch (NumberFormatException nfe) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, nfe.toString());
    return;
  }
  if (pathComponents.hasNext()) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Path too long");
    return;
  }

  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) {
    response.sendError(HttpServletResponse.SC_NOT_FOUND, nsue.toString());
  } catch (NotReadyException nre) {
    response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString());
  } catch (TasteException te) {
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.toString());
    getServletContext().log("Unexpected error in " + getClass().getSimpleName(), te);
  } catch (IllegalArgumentException iae) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, iae.toString());
  } catch (UnsupportedOperationException uoe) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, uoe.toString());
  }
}
 
Example #29
Source File: RecommendToAnonymousServlet.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

  CharSequence pathInfo = request.getPathInfo();
  if (pathInfo == null) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path");
    return;
  }
  Iterator<String> pathComponents = SLASH.split(pathInfo).iterator();
  Pair<long[],float[]> itemIDsAndValue;
  try {
    itemIDsAndValue = parseItemValuePairs(pathComponents);
  } catch (NoSuchElementException nsee) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString());
    return;
  } catch (NumberFormatException nfe) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, nfe.toString());
    return;
  }

  if (itemIDsAndValue.getFirst().length == 0) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No items");
    return;
  }

  long[] itemIDs = itemIDsAndValue.getFirst();
  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) {
    response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString());
  } catch (NoSuchItemException nsie) {
    response.sendError(HttpServletResponse.SC_NOT_FOUND, nsie.toString());
  } catch (TasteException te) {
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.toString());
    getServletContext().log("Unexpected error in " + getClass().getSimpleName(), te);
  } catch (IllegalArgumentException iae) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, iae.toString());
  }
}
 
Example #30
Source File: RecommendToManyServlet.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

  CharSequence pathInfo = request.getPathInfo();
  if (pathInfo == null) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path");
    return;
  }
  Iterator<String> pathComponents = SLASH.split(pathInfo).iterator();
  FastIDSet userIDSet = new FastIDSet();
  try {
    while (pathComponents.hasNext()) {
      userIDSet.add(Long.parseLong(pathComponents.next()));
    }
  } catch (NoSuchElementException nsee) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString());
    return;
  } catch (NumberFormatException nfe) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, nfe.toString());
    return;
  }

  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) {
    response.sendError(HttpServletResponse.SC_NOT_FOUND, nsue.toString());
  } catch (NotReadyException nre) {
    response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString());
  } catch (TasteException te) {
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.toString());
    getServletContext().log("Unexpected error in " + getClass().getSimpleName(), te);
  } catch (IllegalArgumentException iae) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, iae.toString());
  }
}