# Using cosine similarity to measure similarity between uses is not correct

I have a theoretical question. I have implemented a recommender system using collaborative filtering method. There, I am using cosine similarity method to calculate similarity between two users. I have user-item ratings matrix and I get two raws(user feature vectors) and calculate cosine similarity. As an example consider following example vectors.

a = [0 0 0 1 0]
b = [0 0 0 0 0]


If I use cosine similarity, I am getting large value for these users as most of the items haven't been rated by both users. So my question is, is it correct to consider having unrated items as similarity between users? IMO, there is no point of using unrated item's ratings to calculate similarity as it is misleading.

What is your idea about this issue? Is any remedy for this issue ?

• When computing the similarity, only the item that rated by both users are under consideration. Mar 28 '17 at 16:53

You only need to consider the set of items that have been rated by both the users, and compute the similarity using those.

Let that set be $I_{a,b}$. Then,

$sim_{a,b} = \sum_{i \in I_{a,b}} a_i b_i$

• Presumably you mean the Union of the two users’ sets and not the intersection
– Sycorax
Jun 15 at 12:01