python numpy euclidean distance calculation between matrices of row vectors

后端 未结 5 1579
一生所求
一生所求 2020-12-28 14:58

I am new to Numpy and I would like to ask you how to calculate euclidean distance between points stored in a vector.

Let\'s assume that we have a numpy.array each ro

5条回答
  •  执念已碎
    2020-12-28 15:54

    import numpy as np
    single_point = [3, 4]
    points = np.arange(20).reshape((10,2))   
    distance = euclid_dist(single_point,points)
    
    def euclid_dist(t1, t2):
        return np.sqrt(((t1-t2)**2).sum(axis = 1))
    

提交回复
热议问题