This is something that was just added to ML and will probably be released with 2.2. For now you can try to copy from the master code: https://github.com/apache/spark/blob/70f9d7f71c63d2b1fdfed75cb7a59285c272a62b/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala#L352 and give it a try.
Yuhao 2017-03-15 21:39 GMT-07:00 lk_spark <lk_sp...@163.com>: > thanks for your reply , what I exactly want to know is : > in package mllib.recommendation , MatrixFactorizationModel have method > like recommendProducts , but I didn't find it in package ml.recommendation. > how can I do the samething as mllib when I use ml. > 2017-03-16 > ------------------------------ > lk_spark > ------------------------------ > > *发件人:*任弘迪 <ryan.hd....@gmail.com> > *发送时间:*2017-03-16 10:46 > *主题:*Re: how to call recommend method from ml.recommendation.ALS > *收件人:*"lk_spark"<lk_sp...@163.com> > *抄送:*"user.spark"<user@spark.apache.org> > > if the num of user-item pairs to predict aren't too large, say millions, > you could transform the target dataframe and save the result to a hive > table, then build cache based on that table for online services. > > if it's not the case(such as billions of user item pairs to predict), you > have to start a service with the model loaded, send user to the service, > first match several hundreds of items from all items available which could > itself be another service or cache, then transform this user and all items > using the model to get prediction, and return items ordered by prediction. > > On Thu, Mar 16, 2017 at 9:32 AM, lk_spark <lk_sp...@163.com> wrote: > >> hi,all: >> under spark2.0 ,I wonder to know after trained a >> ml.recommendation.ALSModel how I can do the recommend action? >> >> I try to save the model and load it by MatrixFactorizationModel >> but got error. >> >> 2017-03-16 >> ------------------------------ >> lk_spark >> > >