Created
June 24, 2016 14:48
-
-
Save danared/487623574da720956a3e13b66a1b7cfb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get user recommendations | |
import sqlContext.implicits._ | |
val unratedMovies = movieRatings.filter(s"user_id != $userId").select("movie_id").distinct().map(r => | |
(userId, r.getAs[Int]("movie_id"))).toDF("user_id", "movie_id") | |
val recommendations = combinedModel.transform(unratedMovies) | |
// Convert the recommendations into UserMovieRatings | |
val userRecommendations = recommendations.map(r => | |
UserMovieRating(0, r.getAs[Int]("movie_id"), r.getAs[Float]("prediction").toInt)).toDF() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment