search for: datmatt

Displaying 1 result from an estimated 1 matches for "datmatt".

Did you mean: datmat
2006 Jun 07
1
knn - 10 fold cross validation
Hi, I was trying to get the optimal 'k' for the knn. To do this I was using the following function : knn.cvk <- function(datmat, cl, k = 2:9) { datmatT <- (datmat) cv.err <- cl.pred <- c() for (i in k) { newpre <- as.vector(knn.cv(datmatT, cl, k = i)) cl.pred <- cbind(cl.pred, newpre) cv.err <- c(cv.err, sum(cl != newpre)) } k0 <- k[which.min(cv.err)] print(k0) return(k0) } However, the k...