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

slice training outside of loop #1313

Merged
merged 1 commit into from
May 24, 2024
Merged

slice training outside of loop #1313

merged 1 commit into from
May 24, 2024

Conversation

EmilHvitfeldt
Copy link
Member

To close #1305

This PR

library(tidyverse)
library(recipes)

make_factor <- function(x) {
  factor(sample(c("A", "B"), 100, TRUE), levels = c("A", "B"))
} 

x <- map(1:1001, make_factor) %>%
  set_names(c("outcome", paste0("x", 1:1000))) %>%
  as_tibble()

rec <- recipe(outcome ~ ., data = x) %>%
  step_dummy(all_nominal_predictors())

tictoc::tic()
tmp <- prep(rec)
tictoc::toc()
#> 0.762 sec elapsed

Main

library(tidyverse)
library(recipes)

make_factor <- function(x) {
  factor(sample(c("A", "B"), 100, TRUE), levels = c("A", "B"))
} 

x <- map(1:1001, make_factor) %>%
  set_names(c("outcome", paste0("x", 1:1000))) %>%
  as_tibble()

rec <- recipe(outcome ~ ., data = x) %>%
  step_dummy(all_nominal_predictors())

tictoc::tic()
tmp <- prep(rec)
tictoc::toc()
#> 5.01 sec elapsed

@EmilHvitfeldt EmilHvitfeldt merged commit 54cb3a1 into main May 24, 2024
9 checks passed
@EmilHvitfeldt EmilHvitfeldt deleted the faster-step_dummy branch May 24, 2024 19:23
Copy link

github-actions bot commented Jun 8, 2024

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 Jun 8, 2024
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.

Figure out why step_dummy() is slow with many dummy variables
1 participant