Pergunta

I want to make similar graphs to this given on the picture: enter image description here

I am using Fisher Iris data and employ PCA to reduce dimensionality. this is code:

load fisheriris
[pc,score,latent,tsquare,explained,mu] = princomp(meas); 

I guess the eigenvalues are given in Latent, that shows me only four features and is about reduced data.

My question is how to show all eigenvalues of original matrix, which is not quadratic (150x4)? Please help! Thank you very much in advance!

Foi útil?

Solução

The short (and useless) answer is that the [V, D] eig(_) function gives you the eigenvectors and the eigenvalues. However, I'm afraid I have bad news for you. Eigenvalues and eigenvectors only exist for square matrices, so there are no eigenvectors for your 150x4 matrix.

All is not lost. PCA actually uses the eigenvalues of the covariance matrix, not of the original matrix, and the covariance matrix is always square. That is, if you have a matrix A, the covariance matrix is AAT.

The covariance matrix is not only square, it is symmetric. This is good, because the singular values of a matrix are related to the eigenvalues of it's covariance matrix. Check the following Matlab code:

A = [10 20 35; 5 7 9]; % A rectangular matrix
X = A*A';              % The covariance matrix of A

[V, D] = eig(X);       % Get the eigenvectors and eigenvalues of the covariance matrix
[U,S,W] = svd(A);      % Get the singular values of the original matrix

V is a matrix containing the eigenvectors, and D contains the eigenvalues. Now, the relationship:

SST ~ D

U ~ V

I use '~' to indicate that while they are "equal", the sign and order may vary. There is no "correct" order or sign for the eigenvectors, so either is valid. Unfortunately, though, you will only have four features (unless your array is meant to be the other way around).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top