Cosine similarity yields 'nan' values
问题 I was calculating a Cosine Similarity Matrix for sparse vectors, and the elements expected to be float numbers appeared to be 'nan'. 'visits' is a sparse matrix showing how many times each user has visited each website. This matrix used to have a shape 1 500 000 x 1500, but I converted it into sparse matrix, using coo_matrix().tocsc(). The task is to find out, how similar the websites are, so I decided to calculate the cosine metric between each two sites. Here is my code: cosine_distance