配方对象是从创建的食谱包,用于其数据预处理工具集。这些方法通过按顺序定义每个预处理步骤来工作。然而,每个步骤的实现都会产生自己的类,因此我们在这里捆绑与配方对象相关的所有 ax 方法。请注意,屠宰类仅作为一个整体添加到配方中,而不是添加到每个预处理步骤中。
用法
# 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, ...)
例子
library(recipes)
#> Loading required package: dplyr
#>
#> Attaching package: ‘dplyr’
#> The following object is masked from ‘package:randomForest’:
#>
#> combine
#> The following object is masked from ‘package:MASS’:
#>
#> select
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
#>
#> Attaching package: ‘recipes’
#> The following object is masked from ‘package:stats’:
#>
#> step
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)
#> ✔ Memory released: 68.15 kB
# 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)
#> ✔ Memory released: 8.11 MB
# Replace prepared training data with zero-row slice
cleaned2 <- axe_fitted(wrapped_recipes(), verbose = TRUE)
#> ✔ Memory released: 296 B
# Check size
lobstr::obj_size(cleaned1)
#> 13.09 kB
lobstr::obj_size(cleaned2)
#> 8.02 MB
相关用法
- R butcher axe-ranger 砍掉一名护林员。
- R butcher axe-rpart 砍掉一个零件。
- R butcher axe-randomForest 砍掉随机森林。
- R butcher axe-rda 取消 RDA。
- R butcher axe-flexsurvreg 砍掉一个flexsurvreg。
- R butcher axe-ipred 砍倒一棵装袋的树。
- R butcher axe-train.recipe 砍掉一个 train.recipe 对象。
- R butcher axe-terms 取消术语输入。
- R butcher axe-survreg 砍掉一个 survreg。
- R butcher axe-mda 砍掉 mda。
- R butcher axe-earth 砍伐地球物体。
- R butcher axe-spark 砍掉一个Spark物体。
- R butcher axe-gausspr 砍掉高斯。
- R butcher axe-survreg.penal 取消监管处罚
- R butcher axe-glmnet 砍掉 glmnet。
- R butcher axe-nnet 砍掉一个网络。
- R butcher axe-formula 取消公式。
- R butcher axe-kknn 砍掉 kknn。
- R butcher axe-bart 砍掉巴特模型。
- R butcher axe-sclass 砍掉一个 sclass 对象。
- R butcher axe-model_fit 取消 model_fit。
- R butcher axe-multnet 砍掉多网。
- R butcher axe-gam 砍掉一个游戏。
- R butcher axe-mass 砍掉 MASS 判别分析对象。
- R butcher axe-lm 砍掉一部电影。
注:本文由纯净天空筛选整理自Davis Vaughan等大神的英文原创作品 Axing a recipe object.。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。