r descr_models("nearest_neighbor", "kknn")

Tuning Parameters

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

Translation from parsnip to the original package (regression)

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.

Translation from parsnip to the original package (classification)

nearest_neighbor(
  neighbors = integer(1),
  weight_func = character(1),
  dist_power = double(1)
) %>% 
  set_engine("kknn") %>% 
  set_mode("classification") %>% 
  translate()

Preprocessing requirements



Examples

The "Fitting and Predicting with parsnip" article contains examples for nearest_neighbor() with the "kknn" engine.

Case weights


Saving fitted model objects


References



Try the parsnip package in your browser

Any scripts or data that you put into this service are public.

parsnip documentation built on Aug. 18, 2023, 1:07 a.m.