kknn objects are created from the kknn package, which is utilized to do weighted k-Nearest Neighbors for classification, regression and clustering.

# S3 method for kknn
axe_call(x, verbose = FALSE, ...)

# S3 method for kknn
axe_env(x, verbose = FALSE, ...)

# S3 method for kknn
axe_fitted(x, verbose = FALSE, ...)

Arguments

x

A model object.

verbose

Print information each time an axe method is executed. Notes how much memory is released and what functions are disabled. Default is FALSE.

...

Any additional arguments related to axing.

Value

Axed kknn object.

Examples

# Load libraries suppressWarnings(suppressMessages(library(parsnip))) suppressWarnings(suppressMessages(library(rsample))) suppressWarnings(suppressMessages(library(rpart))) suppressWarnings(suppressMessages(library(kknn))) # Load data set.seed(1234) split <- initial_split(kyphosis, props = 9/10) spine_train <- training(split) # Create model and fit kknn_fit <- nearest_neighbor(mode = "classification", neighbors = 3, weight_func = "gaussian", dist_power = 2) %>% set_engine("kknn") %>% fit(Kyphosis ~ ., data = spine_train) out <- butcher(kknn_fit, verbose = TRUE)
#> Memory released: '6,768 B'
# \donttest{ # Another kknn model object m <- dim(iris)[1] val <- sample(1:m, size = round(m/3), replace = FALSE, prob = rep(1/m, m)) iris.learn <- iris[-val,] iris.valid <- iris[val,] kknn_fit <- kknn(Species ~ ., iris.learn, iris.valid, distance = 1, kernel = "triangular") out <- butcher(kknn_fit, verbose = TRUE)
#> Memory released: '46,376 B'
#> Disabled: `print()`, `summary()`, `fitted()`
# }