Calculate PCA score from coefficient and original data
20 views (last 30 days)
Show older comments
Hi all,
I want to do cross validation of a non-linear regression on principal components as input. Therefore, I do PCA on my training set, and use the regression coefficient to transform the standardized test set into their principal components. However in the following I found pc score!=zscore(data)*coef. Appreciate if anyone can explain to me. Thanks alot.
[coef2, score2, latent2, explained2, mu2] = pca(data_raw_ccc(:,2:end));
zdata=zscore(data_raw_ccc(:,2:end));
score3=zdata*coef2;
diff=score3-score2; % NOT EQUAL 0, WHY?
0 Comments
Accepted Answer
the cyclist
on 10 Apr 2015
Edited: the cyclist
on 10 Apr 2015
By default, pca centers the data around the mean, but does not scale it to unit variance.
The original data can be reconstructed by
score2*coef2
5 Comments
the cyclist
on 26 Dec 2020
Four years after-the-fact, I have seen this reply. Yes, you are correct. It should be
score2*coef2'
:-)
More Answers (0)
See Also
Categories
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!