Skip to content

Instantly share code, notes, and snippets.

@satomacoto
Created April 7, 2013 06:17
Show Gist options
  • Save satomacoto/5329272 to your computer and use it in GitHub Desktop.
Save satomacoto/5329272 to your computer and use it in GitHub Desktop.
distance matrix with numpy/scipy
# http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html
from scipy.spatial.distance import squareform, pdist
def test_distance():
X = [[2,3,4],[0,0,0],[1,1,1],[2,2,2]]
print pdist(X, 'euclidean')
print squareform(pdist(X, 'euclidean'))
print squareform(pdist(X, polynomial_kernel))
test_distance()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment