I used PCA on 9-D data. I want to plot PCs direction
1 view (last 30 days)
Show older comments
farshad jahangiri
on 28 Sep 2022
Answered: the cyclist
on 29 Sep 2022
Hi , I extract 2 PC and know I want to plot direction of PCs but I don't know how.
I attached data and code
clc;
clear;
data=importdata('data.txt');
n_data=zscore(data);
[coeff,scores,latent] = pca(n_data,'Algorithm','eig');
p=scatter(scores(:,1),scores(:,2),'filled')
xlabel('Principal Component 1');
ylabel('Principal Component 2');
3 Comments
the cyclist
on 28 Sep 2022
I am confused by what you mean by "direction of PCs".
Because you are plotting the scores variable, you are plotting in principal component space (not the original coordinate space). I would say that the x- and y- axes are the "direction of the PCs" in this plot. (The other 7 PCs are orthogonal to these.)
If this does not make sense, or does not capture what you mean, maybe you could explain some more. What are you trying to illustrate?
Accepted Answer
the cyclist
on 29 Sep 2022
The biplot illustrates what the original axes look like in (two or three dimensions of) PC space.
I think that making a biplot of the inverse of coeff would illustrate what the PC vectors look like in the original space. (I am not certain of this last statement. I'd need to think about it more, and experiment a bit.)
0 Comments
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!