axe-recipe {butcher}R Documentation

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 class 'recipe'
axe_env(x, verbose = FALSE, ...)

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

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

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

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

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

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

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

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

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

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

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

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

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

## S3 method for class 'recipe'
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 recipe object.

Examples


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)


[Package butcher version 0.3.4 Index]