scipy.spatial.distance.cdist(XA, XB, metric='euclidean', p=2, V=None, VI=None, w=None)[source]
Computes distance between each pair of the two collections of inputs.
The following are common calling conventions:
- 
Y = cdist(XA, XB, 'euclidean') Computes the distance between mm points using Euclidean distance (2-norm) as the distance metric between the points. The points are arranged as mm nn-dimensional row vectors in the matrix X. 
>>> a =([1,2],[3,4],[5,6])
>>> a
([1, 2], [3, 4], [5, 6])
>>> b = ([3,4],[7,1])
>>> b
([3, 4], [7, 1])
>>> cdist(a,b)
array([[ 2.82842712,  6.08276253],[ 0.        ,  5.        ],[ 2.82842712,  5.38516481]])
结果数组中第一对第一个值: 【1,2】和 【3,4】的距离;第一对第二个值是【1,2】和【7,1】的距离
 
                    
                     
                    
                 
                    
                 
 
         
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号