KNNModel: Weighted k-Nearest Neighbor Model

Description Usage Arguments Details Value See Also Examples

View source: R/ML_KNNModel.R

Description

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.

Usage

1
2
3
4
5
6
7
KNNModel(
  k = 7,
  distance = 2,
  scale = TRUE,
  kernel = c("optimal", "biweight", "cos", "epanechnikov", "gaussian", "inv", "rank",
    "rectangular", "triangular", "triweight")
)

Arguments

k

numer of neigbors considered.

distance

Minkowski distance parameter.

scale

logical indicating whether to scale predictors to have equal standard deviations.

kernel

kernel to use.

Details

Response Types:

factor, numeric, ordinal

Automatic Tuning of Grid Parameters:

k, distance*, kernel*

* excluded from grids by default

Further model details can be found in the source link below.

Value

MLModel class object.

See Also

kknn, fit, resample

Examples

1
2
3
## Requires prior installation of suggested package kknn to run

fit(Species ~ ., data = iris, model = KNNModel)

MachineShop documentation built on June 18, 2021, 9:06 a.m.