KNN.CV: Cross-Validation with k-Nearest Neighbors Classifier.
Description
This is function performs a 10-fold cross validation on a given data set using k nearest neighbors (kNN) classifier. The output is a vector of predicted labels.
Usage
KNN.CV(x,cl,constrain,kn=10)
Arguments
x
a matrix.
cl
a classification vector.
constrain
a vector of nrow(data) elements. Sample with the same identificative constrain will be split in the training set or in the test test of cross-validation together.
kn
the number of nearest neighbors to consider.
Value
The function returns a vector of predicted labels.
Details
Details are described in Cover, et al. (1967).
References
Cover TM, Hart PE.
TNearest neighbor pattern classification.
IEEE Trans Inf Theory 1967;13(1):21-7.