7.如何计算数组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-01 17:08:36 浏览: 113
euclidean-distance:计算两个数组之间的欧几里得距离
5星 · 资源好评率100%
可以使用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.045361017187261
```
阅读全文