Description Usage Arguments Value Examples
This function splits the data into k groups for evaluating test set and training sets to predict the best value referring the neighbors.
1 | my_knn_cv(train, cl, k_nn, k_cv)
|
train |
Input data frame. |
cl |
True class value of your training data. |
k_nn |
Integer representing the number of neighbors. |
k_cv |
Integer representing the number of folds. |
A list consists of a vector class
comprised of prediction made
by knn()
function from class package, and misclassification
rate cv_err
, a value between 0 and 1 representing the
proportion of observations that were classified incorrectly.
1 2 3 4 | penguins <- STAT302package::my_penguins
penguins2 <- na.omit(penguins)
my_cl <- penguins2 %>% dplyr::pull(species)
result_nn1 <- my_knn_cv(penguins2[, 3:6], my_cl, 1, 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.