Description Usage Arguments Value Examples
Performs k-nearest-neighbors cross validation on dataset to predict classifications of the data.
1 | my_knn_cv(train, cl, k_nn, k_cv)
|
train |
Data frame containing data to train the model. |
cl |
Data frame containing true classification values for the data. |
k_nn |
Numeric denoting how many nearest neighbors to use in the model. |
k_cv |
Numeric denoting number of folds to use in cross validation. |
List containing "class": vector of classification predictions made by the model, "cv_err": numeric containing the average misclasification rate from 0 to 1.
1 2 3 4 5 | height <- c(1.87, 1.45, 1.67, 1.82, 1.91, 1.58)
weight <- c(210, 140, 165, 185, 205, 130)
gender <- c("Male", "Female", "Female", "Male", "Male", "Male")
df <- cbind(data.frame(height), data.frame(weight), data.frame(gender))
my_knn_cv(df[,1:2], df[,3], 1, 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.