Description Usage Arguments Value Examples
This function uses k nearest neighbors to train a knn model and test it using k-fold cross validation.
1 | my_knn_cv(train, cl, k_nn, k_cv)
|
train |
a matrix representing the prediction variables for the result |
cl |
a numeric vector indicating the true result |
k_nn |
the number of nearest neighbors to use when training the model |
k_cv |
the number of folds to use when performing cross-validation |
a list with the predicted values of cl and the mean squared error of the cross-validation testing
1 2 3 | subset <- my_gapminder[c("year", "lifeExp", "pop")]
resp <- my_gapminder %>% dplyr::pull(gdpPercap)
my_knn_cv(subset, resp, 2, 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.