I want to check my implementation of dimensionality reduction with PCA, so I'm looking for a test case. I have found other implementations on the web as well, so I will be comparing with those too.
Can anyone give me a test case, where I have an $N \times D_1$ data matrix and I want to keep $D_2$ components after PCA, so let's say $N = 4$, $D_1 = 5$ and $D_2 = 3$, in other words, I have 5 features from 4 samples, and I want to do PCA and keep 3 components. Given that PCA does not have any randomness, a dataset should give the same output in different implementations of PCA, right?
If anyone is interested, what I'm doing (in MATLAB) is:
[COEFF,SCORE,latent] = princomp(data);
D2 = min(find((cumsum(latent)./sum(latent))>0.9)); % or simply 3 for this case
reduced_testdata = bsxfun(@minus, testdata, mean(traindata)) * COEFF;
P.S: examples for other dimensionality reduction methods (like LDA and CCA) are also very welcome, as they can help me or other users to check their code as well.