my_knn_cv: K-nearest neighbors cross validation method

Description Usage Arguments Value Examples

View source: R/my_knn_cv.R

Description

This function predict output class species using covariates bill_length_mm, bill_depth_mm, flipper_length_mm, and body_mass_g. We will be using a 5-fold cross validation to test whether it is working or not.

Usage

1
my_knn_cv(train, cl, k_nn, k_cv)

Arguments

train

input data frame.

cl

true class value of your training data.

k_nn

integer representing the number of neighbors.

k_cv

integer representing the number of folds.

Value

a list that contain objects; *class: a vector of the predicted class $\hatY_i$ for all observations *cv_err: a numeric with the cross-validation misclassification error

Examples

1
my_knn_cv(data_p[, -1], data_p[, 1], 5, 5)

anasmuhd/FirstPackage documentation built on Dec. 19, 2021, 2:33 a.m.