knn.search: Search Nearest Neighbors

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Return index and distance for the k nearest neighbors of each observation. Neighbors are obtained using the canonical Euclidian distance.

Usage

1

Arguments

data

an input data.frame or matrix Where each line corresponds to an observation.

k

the maximum number of nearest neighbors to search.

Details

Neighbors are found using the kd-tree algorithm.

Value

index

an n x k matrix of nearest neighbor indices.

dist

an n x k matrix of nearest neighbor distances.

Author(s)

The function has been implemented by Kai Li.

See Also

knn.emp for empirical estimation of the risk, knn.boot for an exact bootstrap estimation, and knn.cv for cross-validated estimation for the kNN algorithm.

Examples

1
2
3
data(Spam)
spam.data <- Spam[,-58]
knn.search(data=spam.data,k=7)

ExactSampling documentation built on May 2, 2019, 6:08 p.m.