我想用 mahout 实现分页(指定、偏移和最大结果)我如何用 Mahout 实现它?所以假设我有这个生成推荐的代码
File ratingsFile = new File("audio-dummy-bool.csv");
DataModel model = new FileDataModel(ratingsFile);
CachingRecommender cachingRecommender2 = new CachingRecommender(new SlopeOneRecommender(model));
// for all users
for (LongPrimitiveIterator it = model.getUserIDs(); it.hasNext();){
long userId = it.nextLong();
// get the recommendations for the user
List<RecommendedItem> recommendations = cachingRecommender.recommend(userId, 10);
// if empty write something
if (recommendations.size() == 0){
System.out.print("User ");
System.out.print(userId);
System.out.println(": no recommendations");
}
// print the list of recommendations for each
for (RecommendedItem recommendedItem : recommendations) {
System.out.print("User ");
System.out.print(userId);
System.out.print(": ");
System.out.println(recommendedItem);
}
}
我想为此实现一个分页,因为该推荐可能会为用户生成一千个结果,这将花费大量内存。无论如何我可以在 mahout 中指定生成建议的最大结果和偏移量吗?