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

Feature one_hot argument for step_dummy() #145

Merged
merged 2 commits into from Apr 17, 2018
Merged

Feature one_hot argument for step_dummy() #145

merged 2 commits into from Apr 17, 2018

Conversation

DavisVaughan
Copy link
Member

Since I sadly deleted the PR #136 branch with one_hot, I could not reopen it and have reimplemented it here, incorporating your comments from there.

I have not removed the contrasts argument, as I feel that is a separate feature.

@DavisVaughan
Copy link
Member Author

DavisVaughan commented Apr 16, 2018

Regarding the contrasts argument, trying the code below with all 5 of the different unordered contrast types set as global options results in behavior mimicking a fallback to using the default, contr.treatment, with one_hot = TRUE. This probably makes sense right?

data(okc)
okc <- okc[complete.cases(okc),]

rec <- recipe(~ diet + age + height, data = okc)

rec %>% 
  step_dummy(diet, one_hot = TRUE) %>%
  prep(training = okc) %>%
  bake(newdata = okc)

I think the bit of model.matrix() that determines what to do in these cases happens at the C level, I'm not exactly sure where, but maybe this bit has something to do with it.

@topepo
Copy link
Member

topepo commented Apr 17, 2018

Regarding the contrasts argument, trying the code below with all 5 of the different unordered contrast types set as global options results in behavior mimicking a fallback to using the default, contr.treatment, with one_hot = TRUE. This probably makes sense right?

It does. I added to the dummy variable vignette to mention this.

@topepo topepo merged commit 845a564 into tidymodels:master Apr 17, 2018
@topepo topepo mentioned this pull request Apr 17, 2018
@github-actions
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants