Database Reference
In-Depth Information
Mean Squared Error
The Mean Squared Error ( MSE ) is a direct measure of the reconstruction error of the
user-item rating matrix. It is also the objective function being minimized in certain models,
specifically many matrix-factorization techniques, including ALS . As such, it is commonly
used in explicit ratings settings.
It is defined as the sum of the squared errors divided by the number of observations. The
squared error, in turn, is the square of the difference between the predicted rating for a giv-
en user-item pair and the actual rating.
We will use our user 789 as an example. Let's take the first rating for this user from the
moviesForUser set of Ratings that we previously computed:
val actualRating = moviesForUser.take(1)(0)
Here is the output:
actualRating: org.apache.spark.mllib.recommendation.Rating =
Rating(789,1012,4.0)
We will see that the rating for this user-item combination is 4. Next, we will compute the
model's predicted rating:
val predictedRating = model.predict(789,
actualRating.product)
The output of the model's predicted rating is as follows:
...
14/04/13 13:01:15 INFO SparkContext: Job finished: lookup at
MatrixFactorizationModel.scala:46, took 0.025404 s
predictedRating: Double = 4.001005374200248
We will see that the predicted rating is about 4, very close to the actual rating. Finally, we
will compute the squared error between the actual rating and the predicted rating:
val squaredError = math.pow(predictedRating -
actualRating.rating, 2.0)
Search WWH ::




Custom Search