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

Get rotated data from ml_pca() #483

Closed
richierocks opened this issue Feb 10, 2017 · 1 comment
Closed

Get rotated data from ml_pca() #483

richierocks opened this issue Feb 10, 2017 · 1 comment
Labels

Comments

@richierocks
Copy link
Contributor

If I run a PCA using stats::prcomp(), I get the rotated data returned. That is, a matrix where each row contains data for a row of input data, and each column contains data for a principal component.

For example,

pca_model_local <- prcomp(USArrests, scale = TRUE)
pca_model_local$x

If I use ml_pca(), I don't get this matrix back.

sc <- spark_connect("local")
us_arrests <- copy_to(sc, USArrests)
pca_model_spark <- us_arrests %>% ml_pca()
str(pca_model_spark)
@dsblr
Copy link

dsblr commented May 19, 2017

@richierocks try pca_model_spark$components you will get the rotation.

iris_dat <- copy_to(sc,iris, overwrite = TRUE)
ir_pc_dat <- iris_dat %>% select(-Species) %>% ml_pca()
ir_pc_dat$components

             PC1         PC2         PC3        PC4
Sepal_Length -0.36138659 -0.65658877  0.58202985  0.3154872
Sepal_Width   0.08452251 -0.73016143 -0.59791083 -0.3197231
Petal_Length -0.85667061  0.17337266 -0.07623608 -0.4798390
Petal_Width  -0.35828920  0.07548102 -0.54583143  0.7536574

Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants