3 ms·
I found this line confusing: > The printed lines above show that both algorithms capture more than 50% of the variance exhibited in the data using only 4 of th
by wjn0 8y ago
I found this line confusing:
> The printed lines above show that both algorithms capture more than 50% of the variance exhibited in the data using only 4 of the 50 stocks.
Based on the sklearn PCA documentation [1] this has nothing to do with the coefficients on individual stocks, and for PCA should read more like: "[...] capture more than 50% of the variance exhibited in the data using only 4 components [...]" which is not the same thing.
1. http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html http://scikit-learn.org/stable/modules/generated/sklearn.dec...
- pacbard 8y agoNot really. PCA extract components (or factors) using individual items (in this case, each stock). OP points out that those 4 stocks strongly load (large amount of their variation used to calculate the component) on the PCA first component. I would interpret those variances explained more like a way to make sense of the component (maybe stocks of tech companies load on it) rather than a “quality” of extractoin measure. Usually, correlation matrix eigenvalues can be used to get a sense of how well the PCA is performing and how many dimensions are present in the raw data.
- wjn0 8y agoThe idea (ranking stocks by sum of the absolute value of the coefficients) is valid, but that line of code (variance explained by each component) doesn't do that.
- efavdb 8y agoI think your criticism is right. In that line I was thinking about the feature selector, which does pull out 4 of the individual stocks -- these capture more than 50% of the variance in the full set. As you pointed out, that description isn't quite right for the PCA line, which uses four hybrid components.
- makmanalp 8y agoTo expand upon this, in PCA, different components have "loadings" not on single variables but on many variables (a.k.a. columns), which are often highly correlated with each other.