January 2018
Intermediate to advanced
470 pages
11h 9m
English
The ALS algorithm takes the RDD of ratings for training. To do so, the following code illustrates for building the recommendation model using APIs:
val ratingsRDD = trainingData.rdd.map(row => { val userId = row.getString(0) val movieId = row.getString(1) val ratings = row.getString(2) Rating(userId.toInt, movieId.toInt, ratings.toDouble)})
The ratingsRDD is an RDD of ratings that contains userId, movieId, and the corresponding ratings from the training dataset we prepared in the previous step. On the other hand, a test RDD is also required for evaluating the model. The following testRDD also contains the same information coming from the test DataFrame we prepared ...
Read now
Unlock full access