-
-
Save darkseed/f774646721899087e15c to your computer and use it in GitHub Desktop.
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 | |
from scipy.spatial.distance import cdist | |
def nearest_neighbor(samples, targets, samples_to_classify, metric='euclidean'): | |
return targets[np.argmin(cdist(samples_to_classify, samples, metric=metric), axis=1)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment