Results of pca are different

3 views (last 30 days)
Ismaele Bnb
Ismaele Bnb on 13 Nov 2019
Answered: Rajani Mishra on 13 Feb 2020
Hi
I'm doing a porting from matlab to java, and I'm having trouble with PCA. In java i got only first eigenvectors same as matlab's ones. Could this be possible because of explained values are all zeros except for first (that is 100)?
This is matlab function:
[pca_eigenvec, pca_coeff, pca_eigenval, tsquared, explained] = pca(X, 'Economy', false);
Eigenvalues are same, and only first is not zero.
One more thing. If I use first 2 eigenvectors to make a plot, do I get wrong results?
Thanks :D

Answers (1)

Rajani Mishra
Rajani Mishra on 13 Feb 2020
Output argument “explained” from pca() gives the percentage of the total variance explained by each principal component. Explained value returned for the first one is 100 this means 100 percentage of the total variance(i.e total variance) is explained by the first component itself hence you are getting only first eigenvector.
Since the first component explains 100% of all variability, plotting even the second component won’t give wrong results but you will see only the first component displayed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!