my_knn_cv: k-Nearest Neighbors Cross-Validation Function

Description Usage Arguments Value Examples

View source: R/my_knn_cv.R

Description

This function predicts the class of the input using k-Nearest Neighbors and find the cross-validation error.

Usage

1
my_knn_cv(train, cl, k_nn, k_cv)

Arguments

train

Data Frame input containing the training data.

cl

Vector input containing the class of the training data.

k_nn

Numeric input indicating the number nearest neighbors.

k_cv

Numeric input indication the number of folds in the cross validation.

Value

List containing a vector of the predicted class for the train and a numeric indicating the cross-validation misclassification error.

Examples

1
2
3
train <- as.data.frame(rbind(iris3[1:25,,1], iris3[1:25,,2], iris3[1:25,,3]))
cl <- factor(c(rep("s",25), rep("c",25), rep("v",25)))
my_knn_cv(train, cl, 1, 5)

qiguangyan/Project3 documentation built on Dec. 22, 2021, 10:55 a.m.