Skip to content

butcher methods for workflows only butcher the parsnip model, not a recipe #147

@juliasilge

Description

@juliasilge

In butcher, we have methods to axe various components of recipes, but in workflows, the butcher methods only axe components of the parsnip model, not the recipe. Surfaced in tidymodels/butcher#217.

library(tidymodels)
library(butcher)
cars <- mtcars[rep(1:32, each = 10000),] 

base_spec <- 
  boost_tree() %>% 
  set_mode("regression") %>% 
  set_engine("xgboost") 

base_recipe <- 
  recipe(formula = vs ~ ., 
         data = cars)

fit_obj <-
  workflow() %>% 
  add_recipe(base_recipe) %>% 
  add_model(base_spec) %>% 
  fit(cars)

base_recipe %>% prep() %>% butcher() %>% pluck("template")
#> # A tibble: 0 × 11
#> # … with 11 variables: mpg <dbl>, cyl <dbl>, disp <dbl>, hp <dbl>, drat <dbl>,
#> #   wt <dbl>, qsec <dbl>, am <dbl>, gear <dbl>, carb <dbl>, vs <dbl>

fit_obj %>% butcher() %>% extract_preprocessor() %>% pluck("template")
#> # A tibble: 320,000 × 11
#>      mpg   cyl  disp    hp  drat    wt  qsec    am  gear  carb    vs
#>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#>  1    21     6   160   110   3.9  2.62  16.5     1     4     4     0
#>  2    21     6   160   110   3.9  2.62  16.5     1     4     4     0
#>  3    21     6   160   110   3.9  2.62  16.5     1     4     4     0
#>  4    21     6   160   110   3.9  2.62  16.5     1     4     4     0
#>  5    21     6   160   110   3.9  2.62  16.5     1     4     4     0
#>  6    21     6   160   110   3.9  2.62  16.5     1     4     4     0
#>  7    21     6   160   110   3.9  2.62  16.5     1     4     4     0
#>  8    21     6   160   110   3.9  2.62  16.5     1     4     4     0
#>  9    21     6   160   110   3.9  2.62  16.5     1     4     4     0
#> 10    21     6   160   110   3.9  2.62  16.5     1     4     4     0
#> # … with 319,990 more rows

Created on 2022-03-24 by the reprex package (v2.0.1)

I'm going to call this a bug. 🐛

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions