←back to thread

86 points alexop | 3 comments | | HN request time: 1.068s | source
1. raverbashing ◴[] No.43329726[source]
Meanwhile in Python this is just

    (a @ b.T)/(np.linalg.norm(a)*np.linalg.norm(b))
replies(1): >>43330264 #
2. forgotpwd16 ◴[] No.43330264[source]
Because you use numpy. Could as well import cosine_similarity from sklearn.
replies(1): >>43331468 #
3. Etherlord87 ◴[] No.43331468[source]
you could also normalize (divide all components by magnitude) both vectors and simply take the dot product?