No matter the data source or type, rating data is always about behaviors. To rate a movie, you have to decide to see it, watch it, and then rate it based on your experience of seeing the movie. Actual recommender systems learn from rating data in different ways:
- Collaborative filtering: Matches raters based on movie or product similarities used in the past. You can get recommendations based on items liked by people similar to you or on items similar to those you like.
- Content-based filtering: Goes beyond the fact that you watched a movie. It examines the features relative to you and the movie to determine whether a match exists based on the larger categories that the features represent. For instance, if you are a female who likes action movies, the recommender will look for suggestions that include the intersection of these two categories.
- Knowledge-based recommendations: Based on metadata, such as preferences expressed by users and product descriptions. It relies on machine learning and is effective when you do not have enough behavioral data to determine user or product characteristics. This is called a cold start and represents one of the most difficult recommender tasks because you don’t have access to either collaborative filtering or content-based filtering.
Imagine a space made of features and having two points. You can measure the distance between the points. For instance, you could use the Euclidean distance, which is a perfect choice when you have few dimensions, but which fails miserably when you have multiple dimensions because of the curse of dimensionality.
The idea behind the cosine distance is to use the angle created by the two points connected to the space origin (the point where all dimensions are zero) instead. If the points are near, the angle is narrow, no matter how many dimensions are there. If they are far away, the angle is quite large.
Cosine similarity implements the cosine distance as a percentage and is quite effective in telling whether a user is similar to another or whether a film can be associated to another because the same users favor it. The following example locates the movies that are the most similar movies to movie 50, Star Wars.
print (colnames(MovieLense[,50]))
[1] "Star Wars (1977)"
similar_movies <- similarity(MovieLense[,50],
MovieLense[,-50],
method ="cosine",
which = "items")
colnames(similar_movies)[which(similar_movies>0.70)]
[1] "Toy Story (1995)"
"Empire Strikes Back, The (1980)"
[3] "Raiders of the Lost Ark (1981)"
"Return of the Jedi (1983)"