I have the following code:
import numpy as np
from numpy import dot
from numpy.linalg import norm
a = np.array([3, 45, 7, 2])
b = np.array([[2, 54, 13, 15], [2, 54, 13, 14], [2, 54, 13, 13]])
cos_sim = dot(a, b)/(norm(a)*norm(b))
but it fails. The idea is to calculate the cosine similarity of a over b, and get a list like this:
[0.97..., 0.97..., 0.97...]
Can I do this briefly or I need use for?