3
$\begingroup$

I wonder why number of components in H2o PCA algorithm is limited to 9. It is not sure sometimes to be enough.

k: Specify the rank of matrix approximation. This can be a value from 1 to 9 and defaults to 1.

$\endgroup$
3
  • $\begingroup$ Many times, when doing PCA, one would want to break data down into a few interpret-able factors, meaning researchers would only consider the first ~3-4 PCs in their analysis. This is the approach general when using PCA for exploratory factors analysis. $\endgroup$ – ERT Jul 30 '18 at 11:36
  • 1
    $\begingroup$ If you use PCA for visualization might be you are right . But if I want to transform a 100 features to some another space of features and hold significant amount of variance I'd try some larger values $\endgroup$ – NiMa Jul 31 '18 at 16:42
  • $\begingroup$ It would be nice if you specified your R packages and functions you are using $\endgroup$ – ERT Jul 31 '18 at 17:00
3
$\begingroup$

The H2O prcomp algorithm (i.e. PCA) is not limited to 10 components. The limit is the number of columns in your data (or the number of rows if that is smaller).

The online documentation (http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/pca.html and http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/algo-params/k.html) is wrong. (I'll ping someone at H2O.)

Here is quick R script to show this:

library(h2o)
h2o.init()
d <- as.h2o(matrix(runif(2000),nrow = 40, ncol = 50))
m = h2o.prcomp(d, k = 20)
m

I.e. make a matrix of random data, and request the first 20 components.

The output looks like:

Importance of components: 
                            pc1      pc2      pc3      pc4      pc5      pc6      pc7      pc8      pc9     pc10     pc11
Standard deviation     3.569561 0.599236 0.560946 0.529781 0.518060 0.495266 0.477426 0.438890 0.429845 0.417752 0.407795
Proportion of Variance 0.754456 0.021262 0.018631 0.016619 0.015892 0.014524 0.013496 0.011406 0.010940 0.010333 0.009847
Cumulative Proportion  0.754456 0.775718 0.794349 0.810968 0.826859 0.841383 0.854880 0.866285 0.877225 0.887559 0.897405
                           pc12     pc13     pc14     pc15     pc16     pc17     pc18     pc19     pc20
Standard deviation     0.394316 0.386367 0.370733 0.362824 0.354425 0.343219 0.321725 0.304999 0.295844
Proportion of Variance 0.009206 0.008839 0.008138 0.007795 0.007438 0.006975 0.006129 0.005508 0.005182
Cumulative Proportion  0.906612 0.915451 0.923589 0.931384 0.938822 0.945797 0.951926 0.957434 0.962616

Note that only 96.2% of the variance is explained by the first 20 components. If you set k to 40 you will see 100% of the variance explained. If you set k higher than 40 you will get an error message.

Note: the python API will behave identically.

Aside: I needed so many components because this was random data. With data that has more signal it should not need so many to capture most of the variance. But for high-dimensional data, using more than 10 components is a very reasonable thing to do.

$\endgroup$
1
  • 1
    $\begingroup$ That is I was think of it . Actually , I could check it by myself . That k is actually not limited. Thanks a lot , Darren. $\endgroup$ – NiMa Aug 2 '18 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.