我正在尝试使用mahout并开始构建所有内容并查看示例。我最感兴趣的是协同过滤,所以我开始从BookCrossing数据集中查找recomendations的示例。我设法让一切正常,样本运行没有错误。但是,输出是这样的:
INFO: Creating FileDataModel for file /tmp/taste.bookcrossing.
INFO: Reading file info...
INFO: Read lines: 433647
INFO: Processed 10000 users
INFO: Processed 20000 users
INFO: Processed 30000 users
INFO: Processed 40000 users
INFO: Processed 50000 users
INFO: Processed 60000 users
INFO: Processed 70000 users
INFO: Processed 77799 users
INFO: Beginning evaluation using 0.9 of BookCrossingDataModel
INFO: Processed 10000 users
INFO: Processed 20000 users
INFO: Processed 22090 users
INFO: Beginning evaluation of 4245 users
INFO: Starting timing of 4245 tasks in 2 threads
INFO: Average time per recommendation: 296ms
INFO: Approximate memory used: 115MB / 167MB
INFO: Unable to recommend in 1 cases
INFO: Average time per recommendation: 67ms
INFO: Approximate memory used: 107MB / 167MB
INFO: Unable to recommend in 2363 cases
INFO: Average time per recommendation: 72ms
INFO: Approximate memory used: 146MB / 167MB
INFO: Unable to recommend in 5095 cases
INFO: Average time per recommendation: 71ms
INFO: Approximate memory used: 113MB / 167MB
INFO: Unable to recommend in 7596 cases
INFO: Average time per recommendation: 71ms
INFO: Approximate memory used: 130MB / 167MB
INFO: Unable to recommend in 10896 cases
INFO: Evaluation result: 1.0895580110095793
当我检查代码时,我可以看到它是这样的:
RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator();
File ratingsFile = TasteOptionParser.getRatings(args);
DataModel model =
ratingsFile == null ? new BookCrossingDataModel(true) : new BookCrossingDataModel(ratingsFile, true);
IRStatistics evaluation = evaluator.evaluate(
new BookCrossingBooleanRecommenderBuilder(),
new BookCrossingDataModelBuilder(),
model,
null,
3,
Double.NEGATIVE_INFINITY,
1.0);
log.info(String.valueOf(evaluation));
所以这似乎是正确的,但我希望从生成的建议和/或相似之处中看到更多细节。返回的对象是IRStatistics类型,它只显示结果统计信息的一些数字。我应该看看别的地方吗?这个推荐人不是为了获得任何实际建议吗?
答案 0 :(得分:1)
您实际上并未提出建议,此处您只是在进行评估。
Mahout in Action一书(link)中的这个例子可以让您了解如何实际获得推荐。
该示例仅请求针对一个用户的建议,在您的情况下,您将遍历所有用户并获得每个用户的建议,然后您决定如何处理,例如将它们输出到文件。
此示例也不使用数据模型构建器或推荐器构建器,但是通过查看方法签名来解决它应该不难。