Description Usage Arguments Value Examples
This function performs knn cross validation on a set of data.
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 |
list with the following elements: class: a vector of the predicted class y for all observations cv_err: a numeric with the cross-validation misclassification error
1 2 3 4 5 6 7 8 | data <- my_penguins %>%
tidyr::drop_na()
train_data <- data %>%
dplyr::select(bill_length_mm, bill_depth_mm,
flipper_length_mm, body_mass_g)
target_class <- data$species
my_knn_cv(train_data, target_class, 1, 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.