Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bake and juice shuffle columns around #365

Closed
EmilHvitfeldt opened this issue Jul 18, 2019 · 2 comments
Closed

bake and juice shuffle columns around #365

EmilHvitfeldt opened this issue Jul 18, 2019 · 2 comments

Comments

@EmilHvitfeldt
Copy link
Contributor

@EmilHvitfeldt EmilHvitfeldt commented Jul 18, 2019

Minor quality of life issue. The response variable is moved to the end of the data.frame when juice() is called, but stays in its place when bake() is called.

library(recipes)
#> Loading required package: dplyr
#> 
#> Attaching package: 'dplyr'
#> 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
car_rec <- recipe(cyl ~ ., mtcars) %>%
  step_center(all_predictors()) %>%
  step_scale(all_predictors())
car_preped <- prep(car_rec, training = mtcars)
juice(car_preped) %>% colnames()
#>  [1] "mpg"  "disp" "hp"   "drat" "wt"   "qsec" "vs"   "am"   "gear" "carb"
#> [11] "cyl"
bake(car_preped, new_data = mtcars) %>% colnames()
#>  [1] "mpg"  "cyl"  "disp" "hp"   "drat" "wt"   "qsec" "vs"   "am"   "gear"
#> [11] "carb"
sessioninfo::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.0 (2019-04-26)
#>  os       macOS Mojave 10.14.5        
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/Los_Angeles         
#>  date     2019-07-18                  
#> 
#> ─ Packages ──────────────────────────────────────────────────────────────
#>  package     * version    date       lib
#>  assertthat    0.2.1      2019-03-21 [1]
#>  backports     1.1.4      2019-04-10 [1]
#>  class         7.3-15     2019-01-01 [1]
#>  cli           1.1.0      2019-03-19 [1]
#>  crayon        1.3.4      2017-09-16 [1]
#>  digest        0.6.20     2019-07-04 [1]
#>  dplyr       * 0.8.3      2019-07-04 [1]
#>  evaluate      0.14       2019-05-28 [1]
#>  generics      0.0.2      2018-11-29 [1]
#>  glue          1.3.1      2019-03-12 [1]
#>  gower         0.2.1      2019-05-14 [1]
#>  highr         0.8        2019-03-20 [1]
#>  htmltools     0.3.6      2017-04-28 [1]
#>  ipred         0.9-9      2019-04-28 [1]
#>  knitr         1.23       2019-05-18 [1]
#>  lattice       0.20-38    2018-11-04 [1]
#>  lava          1.6.5      2019-02-12 [1]
#>  lubridate     1.7.4      2018-04-11 [1]
#>  magrittr      1.5        2014-11-22 [1]
#>  MASS          7.3-51.4   2019-03-31 [1]
#>  Matrix        1.2-17     2019-03-22 [1]
#>  nnet          7.3-12     2016-02-02 [1]
#>  pillar        1.4.2      2019-06-29 [1]
#>  pkgconfig     2.0.2      2018-08-16 [1]
#>  prodlim       2018.04.18 2018-04-18 [1]
#>  purrr         0.3.2      2019-03-15 [1]
#>  R6            2.4.0      2019-02-14 [1]
#>  Rcpp          1.0.1      2019-03-17 [1]
#>  recipes     * 0.1.6      2019-07-18 [1]
#>  rlang         0.4.0.9000 2019-07-09 [1]
#>  rmarkdown     1.14       2019-07-12 [1]
#>  rpart         4.1-15     2019-04-12 [1]
#>  sessioninfo   1.1.1      2018-11-05 [1]
#>  stringi       1.4.3      2019-03-12 [1]
#>  stringr       1.4.0.9000 2019-06-10 [1]
#>  survival      2.44-1.1   2019-04-01 [1]
#>  tibble        2.1.3      2019-06-06 [1]
#>  tidyr         0.8.3.9000 2019-07-18 [1]
#>  tidyselect    0.2.5      2018-10-11 [1]
#>  timeDate      3043.102   2018-02-21 [1]
#>  vctrs         0.2.0.9000 2019-07-15 [1]
#>  withr         2.1.2.9000 2019-07-09 [1]
#>  xfun          0.8        2019-06-25 [1]
#>  yaml          2.2.0      2018-07-25 [1]
#>  zeallot       0.1.0      2018-01-28 [1]
#>  source                            
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  local                             
#>  Github (r-lib/rlang@a3d7e47)      
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  Github (tidyverse/stringr@0b90f91)
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  Github (tidyverse/tidyr@c6e291c)  
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  Github (r-lib/vctrs@a8fb108)      
#>  Github (r-lib/withr@df85c87)      
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#>  CRAN (R 3.6.0)                    
#> 
#> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

Created on 2019-07-18 by the reprex package (v0.3.0)

@jakubkovac
Copy link
Contributor

@jakubkovac jakubkovac commented Oct 4, 2019

An update to xgboost package makes this even more annoying. While using a recipe in caret and xgboost as a model, xgboost fails to do any prediction due to having the order of the columns in data and newdata different.

@EmilHvitfeldt
Copy link
Contributor Author

@EmilHvitfeldt EmilHvitfeldt commented Dec 5, 2019

This appears to have been solved by #397 so I'm gonna close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.