Using the recommendation model
Now that we have our trained model, we're ready to use it to make predictions.
ALS Model recommendations
Starting Spark v2.0, org.apache.spark.ml.recommendation.ALS
modeling is a blocked implementation of the factorization algorithm that groups "users" and "products" factors into blocks and decreases communication by sending only one copy of each user vector to each product block at each iteration, and only for the product blocks that need that user's feature vector.
Here, we will load the rating data from the movies dataset where each row consists of a user, movie, rating, and a timestamp. We will then train an ALS model by default works on explicit preferences (implicitPrefs
is false
). We will evaluate the recommendation model by measuring the root-mean-square error of rating prediction as follows:
object ALSModeling { def createALSModel() { val ratings = FeatureExtraction.getFeatures(); val Array(training, test) = ratings.randomSplit(Array(0.8...