axe-function: Axing functions.

Description Usage Arguments Value Examples

Description

Functions stored in model objects often have heavy environments and bytecode attached. To avoid breaking any post-estimation functions on the model object, the butchered_function class is not appended.

Usage

1
2
## S3 method for class ''function''
axe_env(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 function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Load libraries
suppressWarnings(suppressMessages(library(caret)))

data(iris)
train_data <- iris[, 1:4]
train_classes <- iris[, 5]

train_fit <- train(train_data, train_classes,
                   method = "knn",
                   preProcess = c("center", "scale"),
                   tuneLength = 10,
                   trControl = trainControl(method = "cv"))

out <- axe_env(train_fit$modelInfo$prob, verbose = TRUE)
out <- axe_env(train_fit$modelInfo$levels, verbose = TRUE)
out <- axe_env(train_fit$modelInfo$predict, verbose = TRUE)

butcher documentation built on June 28, 2021, 9:08 a.m.