Learn R Programming

gencve (version 0.3)

kNN_LOOCV: Select k with Leave-one-out CV

Description

Use leave-one-out CV to select k

Usage

kNN_LOOCV(X, y, kmax=ceiling(length(y)*0.5), plot=FALSE)

Arguments

X
design matrix
y
response vector
kmax
maximum value of k to consider
plot
show plot of mis-classification rate

Value

plot produced

Details

Leave one out CV is used for odd values of k from 1 to kmax.

Examples

Run this code
Xy <- rmix(300) #training data
kNN_LOOCV(Xy[,1:2], Xy[,3], plot=FALSE)

Run the code above in your browser using DataLab