Created
December 14, 2016 18:17
-
-
Save felipessalvatore/f3498474d8ba18e6af2f9f2769ef7c2c to your computer and use it in GitHub Desktop.
Calculating the cosine distance using scipy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.spatial as ss | |
u = np.array([1,2,3]) | |
u1 = np.array([1,2,3]) | |
v = np.array([2,3,-4]) | |
a = ss.distance.cosine(u, v) | |
a1 = ss.distance.cosine(u, u1) | |
print (a,a1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment