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

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

Open
EmilHvitfeldt opened this issue Jul 28, 2024 · 0 comments
Open

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

EmilHvitfeldt opened this issue Jul 28, 2024 · 0 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@EmilHvitfeldt
Copy link
Member

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

@EmilHvitfeldt EmilHvitfeldt added the bug an unexpected problem or unintended behavior label Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant