-
Notifications
You must be signed in to change notification settings - Fork 122
Closed
Description
Hi,
Firstly, thank you for this wonderful package.
I have query regarding the behaviour of adding a step (example below uses step_dummy). When I don't add a formula and perform juice(prepped object, all_predictors()), this returns all variables. It seems by not having a role, then adding step it makes all variables have a role of predictor.
Please see the examples below. I've tried to illustrate the issue in the first one, with expected behaviour in the next two examples.
Please excuse me if I've misused the package.
Best wishes,
Oli
library(recipes);
library(nlme) # for data
# Add individual steps
obj_rec <- recipe(x = as.data.frame(Orthodont)) %>%
add_role(distance, new_role = 'outcome') %>%
add_role(age, new_role = 'predictor') %>%
add_role(Sex, new_role = 'predictor') %>%
step_dummy(Sex)
obj_prep <- prep(obj_rec, training = Orthodont, retain = TRUE)
X <- juice(obj_prep, all_predictors())
head(X) # Expected?
y <- juice(obj_prep, all_outcomes())
head(y)
# No step_dummy
obj_rec <- recipe(x = as.data.frame(Orthodont)) %>%
add_role(distance, new_role = 'outcome') %>%
add_role(age, new_role = 'predictor') %>%
add_role(Sex, new_role = 'predictor')
obj_prep <- prep(obj_rec, training = Orthodont, retain = TRUE)
X <- juice(obj_prep, all_predictors())
head(X)
y <- juice(obj_prep, all_outcomes())
head(y)
# Formula method works fine
obj_rec <- recipe(distance ~ age + Sex, data = as.data.frame(Orthodont)) %>%
step_dummy(Sex)
obj_prep <- prep(obj_rec, training = Orthodont, retain = TRUE)
X <- juice(obj_prep, all_predictors())
head(X)
y <- juice(obj_prep, all_outcomes())
head(y)Metadata
Metadata
Assignees
Labels
No labels