CVerrorknn | R Documentation |
Given a dataset with predictors and a vector with responses, a number of neighbors K, and a number of folds k, the k-fold CV error rate for KNN is calculated.
CVerrorknn(pred, resp, K = 1, k = nrow(pred))
pred |
A dataset with predictors |
resp |
A vector with responses |
K |
The number of neighborhoods to consider when performing KNN |
k |
The number of folds |
The k-fold CV error rate if k is entered, otherwise the LOOCV error rate.
mtcars$am=as.factor(mtcars$am)
CVerrorknn(mtcars[,c("mpg","hp")],mtcars$am)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.