Mllib ALS模型预测误差

时间:2015-06-26 08:00:49

标签: apache-spark machine-learning spark-streaming apache-spark-mllib

在尝试使用scala编译时,模型.predict方法MatrixFactorizationModel面临错误。

 val usersProducts = ratings.map{ case Rating(user, product, rate) => (user, product,rate) }
 val predictions =   model.predict(usersProducts).map{ case Rating(user, product, rate) => ((user, product), rate)}

错误:方法预测的参数不足:(user:Int,product:Int)Double。

1 个答案:

答案 0 :(得分:2)

MatrixFactorizationModel.predict()(user, product)对的RDD或单个用户和产品对作为两个输入参数。请检查API docs

在您的代码中,您应将其更改为:

val usersProducts = ratings.map{ case Rating(user, product, rate) => (user, product) }