1. Learn
  2. /
  3. Courses
  4. /
  5. Anomaly Detection in Python

Exercise

Finding the euclidean distance manually

Euclidean distance is the most popular distance metric in statistics. Its popularity mainly comes from the fact that it is intuitive to understand. It is the Pythagorean theorem applied in Cartesian coordinates.

Practice calculating it with NumPy manually, which is already loaded under its standard alias np.

Instructions

100 XP
  • Subtract M from N (or vice versa), square the results, and save them into squared_diffs.
  • Calculate the sum of the differences into sum_diffs.
  • Find the square root of the sum to find the final distance—dist_MN.