Learn R Programming

uHMM (version 1.0)

selfKNN: Self KNN

Description

This function performs the k-Nearest Neighbour algorithm without class estimation, but only computation of distances and neighbours.

Usage

selfKNN(train, K = 1)

Arguments

train
numeric matrix or data frame.
K
number of neighbours considered.

Value

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.

Examples

Run this code
x<-matrix(runif(10),ncol=2)
plot(x,pch=c("1","2","3","4","5"))
selfKNN(x,K=4)

Run the code above in your browser using DataLab