tidymodels / orbital

Turn Tidymodels Workflows Into Series of Equations
https://orbital.tidymodels.org
Other
18 stars 1 forks source link

step_pca_sparse doesn't remove terms with 0 in them #51

Open EmilHvitfeldt opened 3 months ago

EmilHvitfeldt commented 3 months ago
library(orbital)
library(recipes)
library(embed)
library(dplyr)

mtcars <- as_tibble(mtcars)

rec <- recipe(mpg ~ ., data = mtcars) %>%
  step_pca_sparse(all_predictors(), predictor_prop = 0.2) %>%
  prep()
#> Warning in irlba(x, k, scale = scale., center = center, ...): You're computing
#> too large a percentage of total singular values, use a standard svd instead.

rec |>
  orbital() |>
  print(truncate = FALSE)
#> 
#> ── orbital Object ──────────────────────────────────────────────────────────────
#> • PC1 = cyl * 0 + disp * 0.8646427 + hp * 0.5023873 + drat * 0 + wt * 0 + qsec
#> * 0 + vs * 0 + am * 0 + gear * 0 + carb * 0
#> • PC2 = cyl * 0 + disp * -0.4852534 + hp * 0.8743736 + drat * 0 + wt * 0 + qsec
#> * 0 + vs * 0 + am * 0 + gear * 0 + carb * 0
#> • PC3 = cyl * 0 + disp * 0 + hp * 0 + drat * -0.01086373 + wt * 0 + qsec *
#> -0.999941 + vs * 0 + am * 0 + gear * 0 + carb * 0
#> • PC4 = cyl * 0 + disp * 0 + hp * 0 + drat * 0 + wt * 0.03797671 + qsec * 0 +
#> vs * 0 + am * 0 + gear * 0 + carb * 0.9992786
#> • PC5 = cyl * -0.992033 + disp * 0 + hp * 0 + drat * 0 + wt * 0 + qsec * 0 + vs
#> * 0.1259784 + am * 0 + gear * 0 + carb * 0
#> ────────────────────────────────────────────────────────────────────────────────
#> 5 equations in total.

Created on 2024-07-28 with reprex v2.1.0