getKNNpredictionFromFormula {FRESA.CAD}R Documentation

Predict classification using KNN

Description

This function will return the classification of the samples of a test set using a k-nearest neighbors (KNN) algorithm with euclidean distances, given a formula and a train set.

Usage

	getKNNpredictionFromFormula(model.formula,
	                            trainData,
	                            testData,
	                            Outcome = "CLASS",
	                            nk = 3)

Arguments

model.formula

An object of class formula with the formula to be used

trainData

A data frame with the data to train the model, where all variables are stored in different columns

testData

A data frame similar to trainData, but with the data set to be predicted

Outcome

The name of the column in trainData that stores the variable to be predicted by the model

nk

The number of neighbors used to generate the KNN classification

Value

prediction

A vector with the predicted outcome for the testData data set

prob

The proportion of k neighbors that predicted the class to be the one being reported in prediction

binProb

The proportion of k neighbors that predicted the class of the outcome to be equal to 1

featureList

A vector with the names of the features used by the KNN procedure

Author(s)

Jose G. Tamez-Pena and Antonio Martinez-Torteya

See Also

predict.fitFRESA


[Package FRESA.CAD version 3.4.8 Index]