knearest: The function to find n_clust nearest neighbors of each instance, always removing the index of that instance if it is reported.
Description
The function will find n_clust nearest neighbors of each instance using Fast nearest neighbors (through KD-tree method) but will correct the result if it reports the index of that instance as its neighbors.
Usage
knearest(D, P, n_clust)
Value
The index matrix of K nearest neighbour of each instance
Arguments
D
a query data matrix.
P
an input data matrix
n_clust
the maximum number of nearest neighbors to search
Author
Wacharasak Siriseriwan <wacharasak.s@gmail.com>
Details
This function will perform K-nearest neighbor of instances in P on instances in P based on FNN. Then, it will verify if one of neighbors of each instance is itself then removes if it is.