M03 Item-Based CF-V2 (1)
M03 Item-Based CF-V2 (1)
Filtering
Dr ZK Abdurahman Baizal
• In this matrix user, Amy has already rated and watched movies Pulp Fiction and The
GodFather but hasn’t watched the movie, Forrest Gump.
• We will be using the above matrix for our example and will try to create an item-item
similarity matrix using Cosine Similarity method to determine how similar the movies are
to each other.
Example
• Step 2: To calculate the similarity between the movie Pulp Fiction (P) and Forrest Gump
(F), we will first find all the users who have rated both the movies. In our case, Calvin (C),
Robert (R) and Bradley (B) have rated the movies. We now create two vectors:
Therefore Cosine Similarity between movies Pulp Fiction and Forrest Gump is:
Example
• Similarly, we can calculate the cosine similarity of all the movies and
our final similarity matrix will be:
Example
• Step 3: Now we can predict and fill the ratings for a user for the items he
hasn’t rated yet. So to calculate the rating of user Amy for the movie
Forrest Gump, we will use the calculated similarity matrix along with the
already rated movie by the Amy.
∑!∈# 𝑟$,! ∗ 𝑠𝑖𝑚(𝑖, 𝑝)
𝑝𝑟𝑒𝑑 𝑢, 𝑝 =
∑!∈# 𝑠𝑖𝑚(𝑖, 𝑝)
𝐼 = himpunan item yang pernah di-rating oleh active user dan yang similar dengan item 𝑝
Example
This problem is solved by using the adjusted cosine measure, which subtracts the
user average from the ratings. The values for the adjusted cosine measure
correspondingly range from -1 to +1, as in the Pearson measure
Example
Item1 Item2 Item3 Item4 Item5 Mean-adjusted ratings matrix
Alice 5 3 4 4 ?
User1 3 1 2 3 3
User2 4 3 4 3 5
User3 3 3 1 5 4
User4 1 5 5 2 1