Last active
June 5, 2018 17:40
-
-
Save jenkspt/539e8474d46325a7c4f0e408c101f4f3 to your computer and use it in GitHub Desktop.
euclidean distance with numpy broadcasting
This file contains 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 | |
def euclidean(A, B): | |
return np.sqrt(((np.expand_dims(A, axis=-1) - B.T)**2).sum(axis=1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment