We can give these recommendations a sense check by taking a quick look at the titles of the movies a user has rated and the recommended movies. First, we will need to load the movie data, which is one of the datasets we explored in the previous chapter. In the following code we'll collect this data as a Map[Int, String] method, mapping the movie ID to the title:
val movies = sc.textFile("/PATH/ml-100k/u.item") val titles = movies.map(line => line.split("|").take(2)).map(array => (array(0).toInt, array(1))).collectAsMap() titles(123)
The preceding code will produce the following output:
res68: String = Frighteners, The (1996)
For our user 789, we can find out what movies they have rated, take the 10 movies ...