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

Conversation

@DavisVaughan
Copy link
Contributor

@DavisVaughan DavisVaughan commented Apr 16, 2018

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
Contributor Author

@DavisVaughan 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
Collaborator

@topepo 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
3 checks passed
3 checks passed
codecov/patch 100% of diff hit (target 92.64%)
Details
codecov/project 92.65% (+0.01%) compared to a805f3a
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
topepo added a commit that referenced this pull request Apr 17, 2018
@topepo topepo mentioned this pull request Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

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