I am trying to calculate a cosine similarity using Python in order to find similar users basing on ratings they have given to movies. As it can be expected there are a lot of NaN values. I am using movie dataset from Kaggle.

When I use np.dot() on two nd.arrays the outcome is:'nan'. I have checked with np.nansum() that there are some other than 'nan' values.

I do not want to change all 'nan' values to '0' as it would mean that users have given 0 rating to the movies which lead to 'false' similarity between users.

Please, give me some advice regarding how to proceed with this problem.

Thanks in advance.

  • $\begingroup$ Check if the arrays have the same size when you put them in the function. $\endgroup$ – Juan Esteban de la Calle Apr 27 at 14:14
  • $\begingroup$ Can you provide an example matrix? A smaller version of your actual data. $\endgroup$ – n1k31t4 Apr 27 at 16:01
  • $\begingroup$ If you need so more control, implement the dot multiplication function on your own in Python. $\endgroup$ – Shubham Panchal Apr 27 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.