配方對象是從創建的食譜包,用於其數據預處理工具集。這些方法通過按順序定義每個預處理步驟來工作。然而,每個步驟的實現都會產生自己的類,因此我們在這裏捆綁與配方對象相關的所有 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.。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。