Skip to content

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

Closed

Description

@EmilHvitfeldt
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

Activity

  1. added
    bugan unexpected problem or unintended behavior
    on Jul 28, 2024
  2. added this to the milestone on Dec 20, 2024
  3. EmilHvitfeldt commented on Jul 2, 2025

    @EmilHvitfeldt
    MemberAuthor

    closed in #91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions