my_knn_cv: k-Nearest Neighbors Cross-Validation Function

Description Usage Arguments Value Examples

View source: R/my_knn_cv.R

Description

Predicts an output class of a given training data using the k-Nearest Neighbors non-parametric statistical prediction method and cross-validation.

Usage

1
my_knn_cv(train, cl, k_nn, k_cv)

Arguments

train

Data frame of numeric and string values intended as training data (with no NA values).

cl

The true class value of the training data, train (with no NA values).

k_nn

Numeric value representing the number of neighbors.

k_cv

Numeric value representing the number of folds for cross-validation.

Value

List containing predicted class (y-hat) for all observations in train, and a numeric value representing the cross-validation misclassification error.

Examples

1
2
ex_penguins <- na.omit(my_penguins)
my_knn_cv(train = ex_penguins[,c(3:6)], cl = ex_penguins$species, k_nn = 1, k_cv = 5)

achew20/project3Package2021 documentation built on Dec. 18, 2021, 10:22 p.m.