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

Connected

Exercise

Calculating manhattan distance manually

While euclidean distance is very popular, it only scales well beyond two or three-dimensional data. In these cases, you can use manhattan distance as an alternative. It has the advantage of working exceptionally well with datasets with many categorical features.

Practice calculating it manually with NumPy, which has been loaded under its standard alias np.

Instructions

100 XP
  • Find the absolute differences between the elements of M and N.
  • Find the sum of differences to calculate the final manhattan distance.