ranger objects are created from the ranger package, which is used as a means to quickly train random forests. The package supports ensembles of classification, regression, survival and probability prediction trees. Given the reliance of post processing functions on the model object, like importance_pvalues and treeInfo, on the first class listed, the butcher_ranger class is not appended.

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

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

Examples

# Load libraries suppressWarnings(suppressMessages(library(parsnip))) suppressWarnings(suppressMessages(library(rsample))) suppressWarnings(suppressMessages(library(ranger))) # Load data set.seed(1234) split <- initial_split(iris, props = 9/10) iris_train <- training(split) # Create model and fit ranger_fit <- rand_forest(mode = "classification", mtry = 2, trees = 20, min_n = 3) %>% set_engine("ranger") %>% fit(Species ~ ., data = iris_train) out <- butcher(ranger_fit, verbose = TRUE)
#> No memory released. Do not butcher.
# Another ranger object wrapped_ranger <- function() { n <- 100 p <- 400 dat <- data.frame(y = factor(rbinom(n, 1, .5)), replicate(p, runif(n))) fit <- ranger(y ~ ., dat, importance = "impurity_corrected") return(fit) } cleaned_ranger <- axe_fitted(wrapped_ranger(), verbose = TRUE)
#> Memory released: '392 B'
#> Disabled: `predictions()`
#> Could not add 'butchered' class