recipes icon indicating copy to clipboard operation
recipes copied to clipboard

rewrite fun_calls() to not use recursion

Open EmilHvitfeldt opened this issue 1 year ago • 1 comments
trafficstars

I learned about all.names() a couple of days ago. And it works wonders in recipes!

The previous issues we had with long formulas was that fun_calls() was recursive, and it just couldn't handle that large formulas. People were seeing issues with as low as 200 columns.

df <- matrix(rnorm(10 * 10001), ncol = 10001)
df <- as.data.frame(df)
names(df) <- c("y", paste0("x", 1:10000))

library(recipes)

rec <- recipe(DF2formula(df), df)

rec |> prep() |> bake(df)
#> # A tibble: 10 × 10,001
#>        x1     x2     x3      x4      x5      x6      x7     x8       x9     x10
#>     <dbl>  <dbl>  <dbl>   <dbl>   <dbl>   <dbl>   <dbl>  <dbl>    <dbl>   <dbl>
#>  1 -0.697  0.294  0.223  0.314   1.91    0.420  -0.652   2.04  -0.00553 -1.97  
#>  2  0.529  0.845  0.725  1.68    0.0474 -1.35    0.251  -1.51  -0.128   -0.0383
#>  3 -1.10   0.932 -0.642 -1.01    0.497  -0.227   0.170  -1.48  -1.11     0.462 
#>  4  0.152 -0.989  1.26   0.477   2.93   -0.908  -0.503   1.06  -1.38     0.363 
#>  5 -1.37   1.86  -0.887 -0.746  -0.624  -0.621  -0.504   2.15  -1.34    -1.74  
#>  6 -0.919  0.739  1.30   0.0830 -1.43   -0.589   0.0628  0.825  0.0854   0.768 
#>  7  0.561  0.636 -0.565 -0.308   0.738   0.0233 -1.10    0.994  0.504    0.0450
#>  8 -0.859  0.320  0.270  0.179  -0.821   2.39   -0.374  -1.51  -0.145    1.41  
#>  9 -0.366  0.650 -0.665  2.44    0.823   0.0493 -0.0434 -0.504  0.707    0.403 
#> 10  0.391 -0.819 -1.00   0.407  -1.81   -0.340   0.0638 -0.334  1.04    -1.50  
#> # ℹ 9,991 more variables: x11 <dbl>, x12 <dbl>, x13 <dbl>, x14 <dbl>,
#> #   x15 <dbl>, x16 <dbl>, x17 <dbl>, x18 <dbl>, x19 <dbl>, x20 <dbl>,
#> #   x21 <dbl>, x22 <dbl>, x23 <dbl>, x24 <dbl>, x25 <dbl>, x26 <dbl>,
#> #   x27 <dbl>, x28 <dbl>, x29 <dbl>, x30 <dbl>, x31 <dbl>, x32 <dbl>,
#> #   x33 <dbl>, x34 <dbl>, x35 <dbl>, x36 <dbl>, x37 <dbl>, x38 <dbl>,
#> #   x39 <dbl>, x40 <dbl>, x41 <dbl>, x42 <dbl>, x43 <dbl>, x44 <dbl>,
#> #   x45 <dbl>, x46 <dbl>, x47 <dbl>, x48 <dbl>, x49 <dbl>, x50 <dbl>, …

EmilHvitfeldt avatar Feb 02 '24 19:02 EmilHvitfeldt

Some of these CI failure also appear on dev branch

EmilHvitfeldt avatar Feb 02 '24 19:02 EmilHvitfeldt

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[bot] avatar Jun 08 '24 00:06 github-actions[bot]