I am trying to understand how can I calculate the similarity between userid and itemid. Here is the user-based table.The table didn't have rating /score information.

userid | itemid1 | itemid2 | itemid3 ... | itemid10000

1 | 1 | 0 | 1 | 1

2 | 0 | 1 | 1 | 1

3 | 0 | 0 | 0 | 1

1)Can I still use KNN method (like manhattan distance or euclidean distance) and cosine similarity method to calculate the similarity score? If so,how can I get these scores as vector matrix.

2)Suppose we have itemid > 100,000,000, so the table is very sparse. So do we have any method to control sparse data to deal with collaborative filtering problems.


1 Answer 1


Basically with kNN approach you cannot compute similarity between user and product. You can compute similarity between user-user or product-product to give recommendations. kNN methods dont deal really well with sparse matrices, for such matrices matrix decomposition algorithms are better. Here is a good Python library called Surprise Python with implementations of kNN based algorithms, matrix factorization based algorithms and many more.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.