selfKNN {uHMM} | R Documentation |
This function performs the k-Nearest Neighbour algorithm without class estimation, but only computation of distances and neighbours.
selfKNN(train, K = 1)
train |
numeric matrix or data frame. |
K |
number of neighbours considered. |
The function returns a list with the following components:
D |
matrix of squared root of the distances between observations and their nearest neighbours. |
idx |
Index of K nearest neighbours of each observation. |
x<-matrix(runif(10),ncol=2)
plot(x,pch=c("1","2","3","4","5"))
selfKNN(x,K=4)