About PCA and 'manual' decomposition
Afficher commentaires plus anciens
If I try to perform a PCA with elementary functions, I use this code (MATLAB 7.10):
load acetylene.mat
dataset = [x1 x2 x3 y];
[M,N]=size(dataset);
mn=mean(dataset,1);
data=dataset-repmat(mn,M,1);
covariance = 1 / (M-1) * (data')*(data);
[PrinComp,L]=eig(covariance);
L=diag(L);
[values,Lind]=sort(-1*L);
PC = PC(:,Lind);
At this point I tried to compare what I've done with: [a,b]=PCA(dataset). Well, eigenvalues are the same, but the matrix is a little bit different (the second column has the opposite signs).
Thanks.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Dimensionality Reduction and Feature Extraction dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!