4 ms·
Yes, the Numpy example is bad. He should try something like, 1 - np.dot(a,b) / (np.linalg.norm(a) * np.linalg.norm(b))
by ks2048 3y ago
Yes, the Numpy example is bad. He should try something like,
1 - np.dot(a,b) / (np.linalg.norm(a) * np.linalg.norm(b))
- arthurcolle 3y agoI implemented cosine similarity too in the last week or two for something and the 1- threw me for a loop until I looked at the math for another 15 seconds, realized that it didn't make much sense for "Cat" and "Cat" to have 0 similarity haha