powered by
Fit a k-nearest neighbor model for which the k nearest training set vectors (according to Minkowski distance) are found for each row of the test set, and prediction is done via the maximum of summed kernel densities.
KNNModel( k = 7, distance = 2, scale = TRUE, kernel = c("optimal", "biweight", "cos", "epanechnikov", "gaussian", "inv", "rank", "rectangular", "triangular", "triweight") )
numer of neigbors considered.
Minkowski distance parameter.
logical indicating whether to scale predictors to have equal standard deviations.
kernel to use.
MLModel class object.
MLModel
factor, numeric, ordinal
factor
numeric
ordinal
k, distance*, kernel*
k
distance
kernel
* excluded from grids by default
Further model details can be found in the source link below.
kknn, fit, resample
kknn
fit
resample
# NOT RUN { ## Requires prior installation of suggested package kknn to run fit(Species ~ ., data = iris, model = KNNModel) # } # NOT RUN { # }
Run the code above in your browser using DataLab