
Last chance! 50% off unlimited learning
Sale ends in
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.
getKNNpredictionFromFormula(model.formula,
trainData,
testData,
Outcome = "CLASS",
nk = 3)
An object of class formula
with the formula to be used
A data frame with the data to train the model, where all variables are stored in different columns
A data frame similar to trainData
, but with the data set to be predicted
The name of the column in trainData
that stores the variable to be predicted by the model
The number of neighbors used to generate the KNN classification
A vector with the predicted outcome for the testData
data set
The proportion of k neighbors that predicted the class to be the one being reported in prediction
The proportion of k neighbors that predicted the class of the outcome to be equal to 1
A vector with the names of the features used by the KNN procedure