Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. import numpy as np
  2. from scipy.spatial.distance import cdist
  3.  
  4. def nearest_neighbor(samples, targets, samples_to_classify, metric='euclidean'):
  5. return targets[np.argmin(cdist(samples_to_classify, samples, metric=metric), axis=1)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement