# Recover the Top Dimensions in PCA and Their Weights

I have a matrix of users each with his/her page view counts over 50 pages. So, I have data points with 50 dimensions each.

What I wanted to find was --> what combination of pages explains the user data the most?

I did PCA and got that the first component explains 80% of the data's variance.

But I can not figure out how do I get which dimensions contribute the most to that component? i.e. their weights in the linear combination.

Since, PCA component is just the linear combination of individual dimensions, I should be able to do that somehow.

Is my approach wrong or is any method better suited to extract the particular information?

• Look at this and this excellent discussions.
– Krrr
Commented Aug 29, 2017 at 11:19

You're looking for eigenvector that corresponds to first singular value.

The problem with retrieving indices of its nonzero entries will most likely be that most or all entries are nonzero. That is because how PCA works - it finds the rotation of feature space such that its coordinates explain variance best along orthogonal directions.

Sparse PCA is used to retrieve sparse directions that explain the data best, with some constraints.

Sparse PCA is available for example in scikit-learn. You can also try to play with H2O's GLRM which is available in both R an Python.

• thanks for the answer. PCA will have all the 50 dimensions, but I can retrieve the weights and set some threshold as to what is more important right? I will try GLRM (it is a family of models?, any specific algo?) and Sparse PCA..any other method to explore that could get me the desired info? Thanks again :) Commented Aug 29, 2017 at 6:49
• You didn't specify what type of data you have, and GLRMs can model both continuous and categorical. If you're familiar with Eckart-Young theorem (or characterization of PCA as closest, in Frobenius norm, rank-k matrix) you can look up a notebook I have made on similar topic (direct generalization actually, for situations where only some matrix entries are given) here. Commented Aug 29, 2017 at 7:32
• This is continuous data version (don't mind the input data being discrete, for this kind of GLRM you need to assume continuity to make sense). Commented Aug 29, 2017 at 7:34
• @JakubBartczuk I think looking at eigenvector itself is not enough as it ignores eigenvalues. See the links that I posted a s comment to the question.
– Krrr
Commented Aug 29, 2017 at 11:22
• @DataD'oh OP only mentioned directions. I don't see what is the purpose of using eigenvalues, since they only scale the directions. Do you mean that you should guide how many eigenvectors to use? Commented Aug 29, 2017 at 11:38