rpart objects are created from the rpart package, which is used for recursive partitioning for classification, regression and survival trees.

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

# S3 method for rpart
axe_ctrl(x, verbose = FALSE, ...)

# S3 method for rpart
axe_data(x, verbose = FALSE, ...)

# S3 method for rpart
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 rpart object.

Examples

# Load libraries suppressWarnings(suppressMessages(library(parsnip))) suppressWarnings(suppressMessages(library(rsample))) suppressWarnings(suppressMessages(library(rpart))) suppressWarnings(library(lobstr)) # Load data set.seed(1234) split <- initial_split(mtcars, props = 9/10) car_train <- training(split) # Create model and fit rpart_fit <- decision_tree(mode = "regression") %>% set_engine("rpart") %>% fit(mpg ~ ., data = car_train, minsplit = 5, cp = 0.1) out <- butcher(rpart_fit, verbose = TRUE)
#> Memory released: '16,624 B'
# Another rpart object wrapped_rpart <- function() { some_junk_in_environment <- runif(1e6) fit <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis, x = TRUE, y = TRUE) return(fit) } # Remove junk cleaned_rpart <- axe_env(wrapped_rpart(), verbose = TRUE)
#> Memory released: '8,065,384 B'
# Check size lobstr::obj_size(cleaned_rpart)
#> 53,192 B