Exercise

kNN distance score

Once the kNN distance matrix is available, the nearest neighbor distance score can be calculated by averaging the nearest neighbor distances for each point.

Large values of the distance score can be interpreted as indicating the presence of unusual or anomalous points.

Instructions

100 XP
  • Calculate the k-nearest neighbor distance score using the rowMeans() function.
  • Print the row index of the point with the largest distance score.