【发布时间】:2015-10-07 09:02:12
【问题描述】:
我有 MatrixFactorizationModel 对象。如果我试图在通过 ALS.train(...) 构建模型后立即向单个用户推荐产品,那么它需要 300 毫秒(对于我的数据和硬件)。但是如果我将模型保存到磁盘并重新加载,那么推荐需要将近 2000 毫秒。 Spark 也发出警告:
15/07/17 11:05:47 WARN MatrixFactorizationModel: User factor does not have a partitioner. Prediction on individual records could be slow.
15/07/17 11:05:47 WARN MatrixFactorizationModel: User factor is not cached. Prediction could be slow.
15/07/17 11:05:47 WARN MatrixFactorizationModel: Product factor does not have a partitioner. Prediction on individual records could be slow.
15/07/17 11:05:47 WARN MatrixFactorizationModel: Product factor is not cached. Prediction could be slow.
加载模型后如何创建/设置分区器并缓存用户和产品因素?以下方法没有帮助:
model.userFeatures().cache();
model.productFeatures().cache();
我还尝试重新分区这些 rdds 并从重新分区的版本创建新模型,但这也没有帮助。
【问题讨论】:
-
我无法重现您分享的警告消息。你能分享一些代码吗?
标签: apache-spark apache-spark-mllib