Pergunta

I have a data matrix A of size N-by-M. I wanted use PCA for dimensionality reduction. I want to set the dimensions to 'k'.

I understand that after feature extraction, I should get a Nxk matrix.

I have tried pcares as follows,

[residuals,reconstructed] = pcares(A,k)

But this does not help me.

I am also trying to use the dr toolbox (here) This returns me a k-by-k matrix. How do I proceede further?

Any help would be appreciated.

Thank You

Foi útil?

Solução

pcares gives you the residual, which is the error when subtracting the input with the reconstructed input. You can use the pca command. It returns a MxM matrix whose columns are the principle components. You can use the first k of them to construct the feature, just do the following

X = bsxfun(@minus, A, mean(A)) * coeff(:, 1:k);, where coeff is what is returned from the pca command. The function call with bsxfun subtracts the mean (centers the data, as this is what pca did when calculating the output coeff).

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