KNN1: kNN classifier

Description Usage Arguments Value Examples

View source: R/KNN1.R

Description

Classify the input with a k nearest neighbors classifier.

Usage

1
KNN1(data, k.seq)

Arguments

data

A list generated by the function PrepareData. It is a list with two components. One is a vector of labels, the other is a data frame of features. The other element of the list is a data frame of test features.

k.seq

A vector vector of vaues of k that should be tested.

Value

A list with a dataframe of errors with corresponding k and a vector of predictions with the best k

Examples

1
2
3
4
5
# create dataset
path <- "/home/rishabh/mres/ml_comp/data/"
data <- PrepareData(path, mode = 2, sample = TRUE, size = 100)
k.seq <- seq(1, 15, 2)
knn.result <- KNN1(data, k.seq)

rishi1226/classrish documentation built on May 27, 2019, 9:10 a.m.