Posts

Showing posts with the label knn

How can I use LOOCV in R with KNN? [on hold]

Image
How can I use LOOCV in R with KNN? [on hold] I am trying to use KNN with cancer data. At first, I only used separation data into train and test set, but I got unexpected results. So I want to use LOOCV to make sure. I found only LOOCV with generalized linear models. such as glm.fit = glm(mpg ~ horsepower, data=Auto) glm.fit = glm(mpg ~ horsepower, data=Auto) So how can I use LOOCV in R with KNN? EDIT My code wdbc<- read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/wdbc.data",sep=",",stringsAsFactors = FALSE) wdbc<-wdbc[-1] normalize <- function(x) {return ((x-min(x)) / (max(x) - min(x)))} wdbc_n <- as.data.frame(lapply(wdbc[2:31], normalize)) wdbc_train<-wdbc_n[1:469,] wdbc_test<-wdbc_n[470:569,] I uploaded the data and I excluded the first column which is the class label. Then I separated the data into train and test set. However, I want to use LOOCV in the separation instead of my separation above. Pleas...