I have a feature vector of size [4096 x 180], where 180 is the number of samples and 4096 is the feature vector length of each sample.
I want to reduce the dimensionality of the data using PCA.
I tried using the built in pca function of MATLAB [V U]=pca(X)
and reconstructed the data by X_rec= U(:, 1:n)*V(:, 1:n)'
, n
being the dimension I chose. This returns a matrix of 4096 x 180.
Now I have 3 questions:
- How to obtain the reduced dimension?
- When I put
n
as 200, it gave an error as matrix dimension increased, which gave me the assumption that we cannot reduce dimension lesser than the sample size. Is this true? - How to find the right number of reduced dimensions?
I have to use the reduced dimension feature set for further classification.
If anyone can provide a detailed step by step explanation of the pca code for this I would be grateful. I have looked at many places but my confusion still persists.