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 |
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 |
Outcome |
The name of the column in |
nk |
The number of neighbors used to generate the KNN classification |
Value
prediction |
A vector with the predicted outcome for the |
prob |
The proportion of k neighbors that predicted the class to be the one being reported in |
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