Calculating principal component scores from principal component coefficients of the new data
28 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Amin Kassab-Bachi
am 7 Mai 2021
Bearbeitet: Amin Kassab-Bachi
am 12 Mai 2021
Hi all,
I perfomed a PCA on dataset using the function
[coeff,score,latent,~,explained,mu]=pca(TrainingSet.X);
Then I generated new shapes (in the cartesian space) using a reduced number of principal components. Now I need to the principal component scores for these new shapes, but I can't figure out how!
Based on the fact that the original centered training data can be retrieved using
centeredData= score*coeff'
I used the following statements, which did not generate relevant results.
for i= 1:newShapesNum
newShapeScore(i,:)=newShape(i,:)*pinv(coeff(:,1:shapeModesNum)'); % i is the counter of new (generated) observations.
newSvalid=newShapeScore(i,:)*coeff(:,1:shapeModesNum)';
end
UPDATE
I also tried running a pca analysis on the new instances, and requested [score] and [coeff]. The mean shape looked good but using the centeredData formula above did not regenerate the original shape! I don't understand why though..
I'd appreciate your help in finding the principal component scores for the new shapes.
Many thanks
Amin
2 Kommentare
Aditya Patil
am 11 Mai 2021
Can you elaborate on the issue? Are you trying to convert new data as per the pca transformation? Or is the issue that pca transformation of new data is leading to poor results?
Akzeptierte Antwort
Aditya Patil
am 12 Mai 2021
To get the scores for new data, you need to first get the outputs mu and coeff.
X = rand(100, 5);
XTrain = X(1:75, :)
XTest = X(76:100,:)
[coeff,scoreTrain,~,~,explained,mu] = pca(XTrain);
Now, to apply the same transformation, that is to get scores for new data, apply the following equation.
idx = 3; % Keep 3 principal components
scoreTest = (XTest-mu)*coeff(:,1:idx)
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dimensionality Reduction and Feature Extraction finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!