我正在使用MLlib为火花中的隐式数据建立一个推荐系统。我试图找到一个已经实现的功能,向用户提供在培训过程中看不到的推荐,我可以找到任何东西。有人知道这样的函数是否存在吗?否则,有没有人对如何有效地实现它有什么建议?
发布于 2014-05-26 20:30:17
这里没有这个函数。事实上,考虑到您从MLlib获得的简单的基于RDD的模型,给出即时建议并不是真正可行的。你可以在这篇博客文章中看到一个实现,网址是http://blog.cloudera.com/blog/2014/03/why-apache-spark-is-a-crossover-hit-for-data-scientists/:
def recommend(questionID: Int, howMany: Int = 5): Array[(String, Double)] = {
// Build list of one question and all items and predict value for all of them
val predictions = model.predict(tagHashes.map(t => (questionID,t._1)))
// Get top howMany recommendations ordered by prediction value
val topN = predictions.top(howMany)(Ordering.by[Rating,Double](_.rating))
// Translate back to tags from IDs
topN.map(r => (tagHashes.lookup(r.product)(0), r.rating))
}不过,lookup让它变得非常慢。要快速实现建议(如<10ms),您必须将RDD合并到一个核心表示中。
但是,如果您只需要批量推荐,那么像上面这样的方法可以通过joins来提高效率。
https://stackoverflow.com/questions/23742403
复制相似问题