Mllib ALS model predict Error

412 Views Asked by At

Facing error for model.predict method MatrixFactorizationModel saying while trying to compile in scala.

 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)}

Error : not enough arguments for method predict: (user: Int, product: Int)Double.

1

There are 1 best solutions below

0
On

MatrixFactorizationModel.predict() takes either an RDD of (user, product) pairs or a single user and product pair as two input arguments. Please check the API docs.

In your code, you should change it to:

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