Hi Sandeep I think you should use testRatings.mapToPair instead of testRatings.map.
So the code should be JavaPairRDD<Integer,Integer> usersProducts = training.mapToPair( new PairFunction<Rating, Integer, Integer>() { public Tuple2<Integer, Integer> call(Rating r) throws Exception { return new Tuple2<Integer, Integer>(r.user(), r.product()); } } ); It works on my side. Wisely Chen On Wed, May 28, 2014 at 6:27 AM, Sandeep Parikh <sand...@clusterbeep.org>wrote: > I've got a trained MatrixFactorizationModel via ALS.train(...) and now I'm > trying to use it to predict some ratings like so: > > JavaRDD<Rating> predictions = model.predict(usersProducts.rdd()) > > Where usersProducts is built from an existing Ratings dataset like so: > > JavaPairRDD<Integer,Integer> usersProducts = testRatings.map( > new PairFunction<Rating, Integer, Integer>() { > public Tuple2<Integer, Integer> call(Rating r) throws Exception { > return new Tuple2<Integer, Integer>(r.user(), r.product()); > } > } > ); > > The problem is that model.predict(...) doesn't like usersProducts, > claiming that the method doesn't accept an RDD of type Tuple2 however the > docs show the method signature as follows: > > def predict(usersProducts: RDD[(Int, Int)]): RDD[Rating] > > Am I missing something? The JavaRDD is just a list of Tuple2 elements, > which would match the method signature but the compile is complaining. > > Thanks! > >