Collaborative Filtering (CF)-based Recommendation System

From GM-RKB
Jump to navigation Jump to search

A Collaborative Filtering (CF)-based Recommendation System is a model-based recommendation system that implements a collaborative filtering algorithm to solve a collaborative filtering task.



References

2016

import org.apache.spark.mllib.recommendation.ALS
import org.apache.spark.mllib.recommendation.Rating

val data = sc.textFile("your_dir/ratings.dat") val ratings = data.map(_.split("::") match { case Array(user, item, rate, timestamp) => Rating(user.toInt, item.toInt, rate.toDouble) }) val movies = movieRecommendationHelper.getMovieRDD.map( _.split("::")) .map { case Array(movieId,movieName,genre) ⇒ (movieId.toInt ,movieName) } val myRatingsRDD = movieRecommendationHelper.topTenMovies //gets 10 popular movies. See <a href="https://github.com/akashsethi24/Machine-Learning/blob/master/src/main/scala/movie/RecommendMovie.scala">Code</a> for for details val training = ratings.filter { case Rating(userId, movieId, rating) ⇒ (userId * movieId) % 10 <= 3 }.persist val test = ratings.filter { case Rating(userId, movieId, rating) ⇒ (userId * movieId) % 10 > 3}.persist

1992