Learn R Programming

butcher (version 0.3.5)

axe-recipe: Axing a recipe object.

Description

recipe objects are created from the recipes package, which is leveraged for its set of data pre-processing tools. These recipes work by sequentially defining each pre-processing step. The implementation of each step, however, results its own class so we bundle all the axe methods related to recipe objects in general here. Note that the butchered class is only added to the recipe as a whole, and not to each pre-processing step.

Usage

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

# S3 method for step axe_env(x, ...)

# S3 method for step_arrange axe_env(x, ...)

# S3 method for step_filter axe_env(x, ...)

# S3 method for step_mutate axe_env(x, ...)

# S3 method for step_slice axe_env(x, ...)

# S3 method for step_impute_bag axe_env(x, ...)

# S3 method for step_bagimpute axe_env(x, ...)

# S3 method for step_impute_knn axe_env(x, ...)

# S3 method for step_knnimpute axe_env(x, ...)

# S3 method for step_geodist axe_env(x, ...)

# S3 method for step_interact axe_env(x, ...)

# S3 method for step_ratio axe_env(x, ...)

# S3 method for quosure axe_env(x, ...)

# S3 method for recipe axe_fitted(x, verbose = FALSE, ...)

Value

Axed recipe 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
library(recipes)
data(biomass, package = "modeldata")

biomass_tr <- biomass[biomass$dataset == "Training",]
rec <- recipe(HHV ~ carbon + hydrogen + oxygen + nitrogen + sulfur,
              data = biomass_tr) %>%
  step_center(all_predictors()) %>%
  step_scale(all_predictors()) %>%
  step_spatialsign(all_predictors())

out <- butcher(rec, verbose = TRUE)

# Another recipe object
wrapped_recipes <- function() {
  some_junk_in_environment <- runif(1e6)
  return(
    recipe(mpg ~ cyl, data = mtcars) %>%
      step_center(all_predictors()) %>%
      step_scale(all_predictors()) %>%
      prep()
  )
}

# Remove junk in environment
cleaned1 <- axe_env(wrapped_recipes(), verbose = TRUE)
# Replace prepared training data with zero-row slice
cleaned2 <- axe_fitted(wrapped_recipes(), verbose = TRUE)

# Check size
lobstr::obj_size(cleaned1)
lobstr::obj_size(cleaned2)

Run the code above in your browser using DataLab