Skip to content

Instantly share code, notes, and snippets.

@danared danared/mongospark
Created Jun 24, 2016

What would you like to do?
// 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 = =>
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
You can’t perform that action at this time.