Session Ready
Exercise

kNN distance matrix

The kNN distance matrix is a necessary prior step to producing the kNN distance score. The distance matrix has

  • \(n\) rows, where \(n\) is the number of data points
  • \(k\) columns, where \(k\) is the user-chosen number of neighbors.

The entry in row i and column j of the distance matrix is the distance between point i and its jth nearest neighbor.

Instructions 1/4
undefined XP
  • 1
  • 2
  • 3
  • 4
  • Calculate the 5 nearest neighbors distance matrix for the wine data using the function get.knn().
  • Use the head() function to visualize the first 5 rows of the distance matrix.