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

Speed up coerce_to_sparse_data_frame() #66

Open
EmilHvitfeldt opened this issue May 23, 2024 · 0 comments
Open

Speed up coerce_to_sparse_data_frame() #66

EmilHvitfeldt opened this issue May 23, 2024 · 0 comments
Labels
feature a feature request or enhancement

Comments

@EmilHvitfeldt
Copy link
Member

if this works, we also speed up the tibble case.

In my mind, it shouldn't take this long

library(tidymodels)
library(textrecipes)
library(friends)

preped_rec <- recipe(season ~ text, data = friends) %>%
  step_tokenize(text) %>%
  step_tf(text) %>%
  prep()
#> Warning in asMethod(object): sparse->dense coercion: allocating vector of size
#> 8.7 GiB

term_freq <- bake(preped_rec, new_data = NULL, composition = "dgCMatrix")

library(sparsevctrs)

tictoc::tic()
tmp <- coerce_to_sparse_data_frame(term_freq)
tictoc::toc()
#> 1.392 sec elapsed

Created on 2024-05-23 with reprex v2.1.0

@EmilHvitfeldt EmilHvitfeldt added the feature a feature request or enhancement label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant