my_knn_cv: K Nearest Neighbors Cross Validation Function

Description Usage Arguments Value Examples

View source: R/my_knn_cv.R

Description

Function performs cross validation to determine appropriate "k" for k-nearest-neighbors.

Usage

1
my_knn_cv(train, cl, k_nn, k_cv)

Arguments

train

The dataset on which your model will be trained.

cl

The vector containing the actual classes of your observations.

k_nn

The number of nearest neighbors used to predict the class of an observation.

k_cv

The number of folds your training data will be divided into for cross-validation.

Value

A list containing vector "class", which contains the predicted classes using the entire data as training data, and the numeric "cv_err" which is the mean cross-validation error for your chosen "k".

Examples

1
2
3
4

oliverlinehan41/project3package documentation built on Dec. 22, 2021, 4:21 a.m.