НачатьНачать бесплатно

Finding the euclidean distance with SciPy

Instead of writing multiple lines of code to calculate the euclidean distance, you can use SciPy. The library not only contains the euclidean function, but more than 40 other distance metrics—all a single import statement away.

Это упражнение является частью курса

Anomaly Detection in Python

Посмотреть курс

Инструкции к упражнению

  • Import the euclidean function from the relevant scipy module.
  • Use the euclidean() function on M and N.

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

# Import the euclidean function from scipy
from scipy.____.____ import euclidean

M = np.array([14, 17, 18, 20, 14, 12, 19, 13, 17, 20])
N = np.array([63, 74, 76, 72, 64, 75, 75, 61, 50, 53])

# Use the euclidean function on M and N
dist_MN = ____

print(dist_MN)
Редактировать и запускать код