#| child: aaa.Rmd #| include: false
r descr_models("nearest_neighbor", "kknn")
#| label: kknn-param-info #| echo: false 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:
#| label: kknn-param-list #| echo: false #| results: asis param$item
Parsnip changes the default range for neighbors
to c(1, 15)
and dist_power
to c(1/10, 2)
.
#| label: kknn-reg 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.
#| label: kknn-cls nearest_neighbor( neighbors = integer(1), weight_func = character(1), dist_power = double(1) ) |> set_engine("kknn") |> set_mode("classification") |> translate()
#| child: template-makes-dummies.Rmd
#| child: template-same-scale.Rmd
The "Fitting and Predicting with parsnip" article contains examples for nearest_neighbor()
with the "kknn"
engine.
#| child: template-no-case-weights.Rmd
#| child: template-butcher.Rmd
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.