如何计算数组a = np.array([1,2,3,2,3,4,3,4,5,6])和数组b = np.array([7,2,10,2,7,4,9,4,9,8])之间的欧式距离
时间: 2023-10-06 19:11:23 浏览: 33
可以使用numpy库中的linalg.norm函数来计算欧式距离,代码如下:
import numpy as np
a = np.array([1,2,3,2,3,4,3,4,5,6])
b = np.array([7,2,10,2,7,4,9,4,9,8])
distance = np.linalg.norm(a-b)
print(distance)
输出结果为:11.704699910719626
阅读全文