knn_classifier: knn Classifier

Description Usage Arguments Value Author(s) Examples

View source: R/knn_classifier.R

Description

Application of knn algorithm for classification

Usage

1
2
3
knn_classifier(data = NULL, p_train = NULL, train = NULL,
  test = NULL, k = 3, target = is.numeric(),
  dist_method = "euclidean", probs = F)

Arguments

data

Dataframe that will be used

p_train

Percentage of rows that will be used as train

train

Dataset used as train set (Only when data and p_train are NULL)

test

Dataset used as test set (Only when data and p_train are NULL)

k

Number of neighbors used

target

Integer with the column number of the target variable

dist_method

Method to calculate the distance between data. Only "Euclidean" available

probs

If TRUE, the results are given in probability. Default is FALSE.

Value

Returns a list with the original dataset + predicted values and a confusion matrix with several data.

Author(s)

Alberto Almui?a

Examples

1
data<-knn(data = iris, p_train = 0.7, target = 5, k = 3)

AlbertoAlmuinha/knnClassifier documentation built on Oct. 30, 2019, 4:48 a.m.