Given a user rating matrix, where several users have rated several products, the goal of collaborative filtering is as follows:
- Predict the ratings for all products unknown to the user
- Produce the ratings for the top-n list of products unknown to the user
The underlying premise of the collaborative filtering algorithm is that if two users agree on ratings for a large set of items, they may tend to agree for other items too. Let us use a small R code snippet to explain this concept. Assume we have seven products (A
, B
, C
, D
, E
, F
, G
) and two users (user.a
and user.b
). We also have the ratings provided by both of the users for some of the products. The ratings are range of numbers from 1 to 5, with 1 indicating a poor rating, 5 indicating a good rating, and 0 indicating no rating.
The following is an R snippet for demonstration purposes:
> set.seed(100) > products <- c('A','B','C','D','E','F','G') > user.a <- c( 3, 0, 2, 5, 5, 0,1) > user.b <-...