Skip to content

Instantly share code, notes, and snippets.

@danared
Created June 24, 2016 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danared/487623574da720956a3e13b66a1b7cfb to your computer and use it in GitHub Desktop.
Save danared/487623574da720956a3e13b66a1b7cfb to your computer and use it in GitHub Desktop.
// 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