Skip to content

Instantly share code, notes, and snippets.

@felipessalvatore
Created December 14, 2016 18:17
Show Gist options
  • Save felipessalvatore/f3498474d8ba18e6af2f9f2769ef7c2c to your computer and use it in GitHub Desktop.
Save felipessalvatore/f3498474d8ba18e6af2f9f2769ef7c2c to your computer and use it in GitHub Desktop.
Calculating the cosine distance using scipy
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