例如,scipy.spatial.distance.pdist可以计算两两向量之间的距离(包括欧氏距离、余弦距离等)
scipy.spatial.distance.pdist
import numpy as np import scipy.spatial.distance as dist arr = np.array([[0,0],[0,1],[1,0],[1,1]]) dist.pdist(arr)