axe-randomForest | R Documentation |
randomForest objects are created from the randomForest
package, which is used to train random forests based on Breiman's
2001 work. The package supports ensembles of classification and
regression trees.
## S3 method for class 'randomForest'
axe_call(x, verbose = FALSE, ...)
## S3 method for class 'randomForest'
axe_ctrl(x, verbose = FALSE, ...)
## S3 method for class 'randomForest'
axe_env(x, verbose = FALSE, ...)
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 |
... |
Any additional arguments related to axing. |
Axed randomForest object.
# Load libraries
library(parsnip)
library(rsample)
library(randomForest)
data(kyphosis, package = "rpart")
# Load data
set.seed(1234)
split <- initial_split(kyphosis, prop = 9/10)
spine_train <- training(split)
# Create model and fit
randomForest_fit <- rand_forest(mode = "classification",
mtry = 2,
trees = 2,
min_n = 3) %>%
set_engine("randomForest") %>%
fit_xy(x = spine_train[,2:4], y = spine_train$Kyphosis)
out <- butcher(randomForest_fit, verbose = TRUE)
# Another randomForest object
wrapped_rf <- function() {
some_junk_in_environment <- runif(1e6)
randomForest_fit <- randomForest(mpg ~ ., data = mtcars)
return(randomForest_fit)
}
# Remove junk
cleaned_rf <- axe_env(wrapped_rf(), verbose = TRUE)
# Check size
lobstr::obj_size(cleaned_rf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.