0
votes

In Python I've calculated the eigenvectors and eigenvalues of my data matrix X through eig(). I'm looking to find the top 2 principal components of the data (U = [u1 u2]). I know the top 2 components are the 2 eigenvectors corresponding to the 2 largest eigenvalues, but I'm not sure how to calculate that information with the data at hand (eigenvalues, eigenvectors, and X).

Eigenvectors and eigenvalues calculated:

 Eigenvectors = [[-0.68065502 -0.72805308 -0.08153196]
                 [-0.71680551  0.68482721 -0.13115467]
                 [-0.15132287  0.03082853  0.98800354]]

 Eigenvalues = [2.84217094e-14  2.15257831e+02  8.95193455e+02]
1
what are you looking to calculate? You already have all the information (eigval, eigvec). What do you need more ?kada
Looking to find the top 2 principal components for PCApython_
Then just take the maximum 2 of your 3 eigenvalues. They are the principal components.kada

1 Answers

0
votes

Given the Eigenvalues you got Eigenvalues = [2.84217094e-14 2.15257831e+02 8.95193455e+02]

Your two largest Eigenvalues are 8.95193455e+02 and 2.15257831e+02, The sum of your eigenvalues is 1110.0 which corresponds to the 100% of the information. So your largest eigenvalue 8.95193455e+02 has 80.6% of the information. The second eigenvalue 2.15257831e+02 has the remaining 19.4% of the information, and the last eigenvalue 2.84217094e-14 is too small, thus it can be considered noise.

For the eigenvectors that match these eigenvalues, each column of your Eigenvectors matrix is associated to one eigenvalue, and they are in the same order.

For example, your first eigenvalue 8.95193455e+02 is associated to the eigenvector

[[-0.08153196]
 [-0.13115467]
 [ 0.98800354]]