
Last chance! 50% off unlimited learning
Sale ends in
This implementation uses sorting of distances to identify the k elements that are nearest to each data point. The result is deterministic and exact.
knn.from.dist(d, k)
dist object or matrix with distances
integer, number of neighbors
list with two components; indexes identifies, for each point in dataset, the set of k neighbors distances provides distances from each point to those neighbors
By definition, the first nearest neighbor to each point is the point itself. Subsequent neighbors are "true" neighbors.