I am given a matrix of ones and zeros. I need to find 20 rows which have the highest cosine metrics towards 1
specific
specific
cosine(1row,5row),cosine(2row,5row),...,cosine(8row,5row),cosine(9row,5row)
A = ratings[:,100]
A = A.reshape(1,A.shape[0])
B = ratings.transpose()
similarity = -cosine(A,B)+1
A.shape = (1L, 71869L)
B.shape = (10000L, 71869L)
Input vector should be 1-D.
scipy
specific
The fastest way is to use matrix operations: something like np.multipy(A,B)