Learn R Programming

butcher (version 0.3.5)

axe-sclass: Axing a sclass object.

Description

sclass objects are byproducts of classbagg objects.

Usage

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

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

Value

Axed sclass object.

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.

Examples

Run this code
if (FALSE) { # rlang::is_installed(c("ipred", "rpart", "MASS", "TH.data"))
# Load libraries
library(ipred)
library(rpart)
library(MASS)

# Load data
data("GlaucomaM", package = "TH.data")

classbagg_fit <- bagging(Class ~ ., data = GlaucomaM, coob = TRUE)

out <- butcher(classbagg_fit$mtrees[[1]], verbose = TRUE)

# Another classbagg object
wrapped_classbagg <- function() {
  some_junk_in_environment <- runif(1e6)
  fit <- bagging(Species ~ .,
                 data = iris,
                 nbagg = 10,
                 coob = TRUE)
  return(fit)
}

# Remove junk
cleaned_classbagg <- butcher(wrapped_classbagg(), verbose = TRUE)

# Check size
lobstr::obj_size(cleaned_classbagg)
}

Run the code above in your browser using DataLab