3 ms·
Meanwhile in Python this is just (a @ b.T)/(np.linalg.norm(a)*np.linalg.norm(b))
by raverbashing 2y ago
Meanwhile in Python this is just
(a @ b.T)/(np.linalg.norm(a)*np.linalg.norm(b))
- forgotpwd16 2y agoBecause you use numpy. Could as well import cosine_similarity from sklearn.
- Etherlord87 2y agoyou could also normalize (divide all components by magnitude) both vectors and simply take the dot product?