r descr_models("nearest_neighbor", "kknn")
defaults <- tibble::tibble(parsnip = c("neighbors", "weight_func", "dist_power"), default = c("5L", "'optimal'", "2.0")) param <- nearest_neighbor() %>% set_engine("kknn") %>% make_parameter_list(defaults)
This model has r nrow(param)
tuning parameters:
param$item
Parsnip changes the default range for neighbors
to c(1, 15)
and dist_power
to c(1/10, 2)
.
nearest_neighbor( neighbors = integer(1), weight_func = character(1), dist_power = double(1) ) %>% set_engine("kknn") %>% set_mode("regression") %>% translate()
min_rows()
will adjust the number of neighbors if the chosen value if it is not consistent with the actual data dimensions.
nearest_neighbor( neighbors = integer(1), weight_func = character(1), dist_power = double(1) ) %>% set_engine("kknn") %>% set_mode("classification") %>% translate()
The "Fitting and Predicting with parsnip" article contains examples for nearest_neighbor()
with the "kknn"
engine.
Hechenbichler K. and Schliep K.P. (2004) Weighted k-Nearest-Neighbor Techniques and Ordinal Classification, Discussion Paper 399, SFB 386, Ludwig-Maximilians University Munich
Kuhn, M, and K Johnson. 2013. Applied Predictive Modeling. Springer.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.