Reputation: 581
I have these two methods which are from a KNN implementation. I gather that they are two distance measurements, however I do not understand how they differ. I've tried looking up the method but haven't had any luck.
def euclideanDistance(in1,in2):
return np.linalg.norm(in1-in2)
def L1Distance(in1,in2):
return np.linalg.norm(in1-in2,1)
Upvotes: 2
Views: 414
Reputation: 1108
The function being called is the same, but in the second case an additional argument is added to change its behaviour.
The second keyword argument is order, and if there is no input for this argument it calculates the euclidian Norm sqrt(in1^2 - in2^2).
If the ord=1 (your case) the L1 norm is calculated, which is abs(in1 - in2)
Upvotes: 2