knn.kodama {KODAMA} | R Documentation

## k-Nearest Neighbors Classifier.

### Description

k-nearest neighbour classification for a test set from a training set.

### Usage

    knn.kodama(Xtrain,
               Ytrain,
               Xtest,
               Ytest=NULL,
               k,
               scaling = c("centering","autoscaling"),
               perm.test=FALSE,
               times=1000)

### Arguments

`Xtrain` | a matrix of training set cases.
`Ytrain` | a classification vector.
`Xtest` | a matrix of test set cases.
`Ytest` | a classification vector.
`k` | the number of nearest neighbors to consider.
`scaling` | the scaling method to be used. Choices are "`centering`" or "`autoscaling`" (by default = "`centering`"). A partial string sufficient to uniquely identify the choice is permitted.
`perm.test` | a classification vector.
`times` | a classification vector.

### Details

The function utilizes the Approximate Nearest Neighbor (ANN) C++ library, which can give the exact nearest neighbours or (as the name suggests) approximate nearest neighbours to within a specified error bound. For more information on the ANN library please visit http://www.cs.umd.edu/~mount/ANN/.

### Value

The function returns a vector of predicted labels.

### Author(s)

Stefano Cacciatore and Leonardo Tenori

### References

Bentley JL (1975)
Multidimensional binary search trees used for associative search.
Communication ACM 1975;18:309-517.

Arya S, Mount DM
Approximate nearest neighbor searching
Proc. 4th Ann. ACM-SIAM Symposium on Discrete Algorithms (SODA'93);271-280.

Arya S, Mount DM, Netanyahu NS, Silverman R, Wu AY
An optimal algorithm for approximate nearest neighbor searching
Journal of the ACM 1998;45:891-923.

Cacciatore S, Luchinat C, Tenori L
Knowledge discovery by accuracy maximization.
Proc Natl Acad Sci U S A 2014;111(14):5117-22. doi: 10.1073/pnas.1220873111. Link
Cacciatore S, Tenori L, Luchinat C, Bennett PR, MacIntyre DA
KODAMA: an updated R package for knowledge discovery and data mining.
Bioinformatics 2017;33(4):621-623. doi: 10.1093/bioinformatics/btw705. Link

### See Also

`KODAMA`

### Examples

     data(iris)
     data=iris[,-5]
     labels=iris[,5]
     ss=sample(150,15)

     z=knn.kodama(data[-ss,], labels[-ss], data[ss,], k=5)
     table(z$Ypred[,5],labels[ss])

[Package KODAMA version 1.5 Index]