import scipy.spatial as sp cos = 1 - sp.distance.cdist(matrix1, matrix2, 'cosine') print(cos)
array([[ 1. , 0.94280904], [ 0.94280904, 1. ]])
原文链接