I'm new in AI and sorry if my question is simple. I have a data set and want to use PCA to decrease the feature but after some research on the internet I'm confused about decreasing dimensions and features.

As an example I have a data set with 50 rows and 10 columns, if I use PCA it will reduce a data set with 50x5 (as an example) or 50x10 and just removed some dimensions?

I want to do it in MATLAB and want to use PCA function and don't want to write PCA function by myself.

What is the PCA parameters in MATLAB to decrease the feature? It's a lot of parameters and confused me.

  • $\begingroup$ My answer referenced parts of your question that you edited out, and I don't know what you want answered in the edited question. $\endgroup$
    – Ben Reiniger
    Apr 23, 2019 at 19:43

1 Answer 1


From the documentation:

coeff = pca(X) returns the principal component coefficients, also known as loadings, for the $n$-by-$p$ data matrix X. Rows of X correspond to observations and columns correspond to variables. The coefficient matrix is $p$-by-$p$. Each column of coeff contains coefficients for one principal component, and the columns are in descending order of component variance. By default, pca centers the data and uses the singular value decomposition (SVD) algorithm.

The values in coef represent the transformation from the original features (rows of coef) to the principal components (columns of coef). You'll want to keep only the first $k$ columns, then multiply your data matrix by this matrix.

Your features are the dimensions that your data lives in, so number of features and dimension are the same. Very roughly speaking, PCA rotates the the feature axes to align to the most significant directions rather than the original feature directions, then selects only the most significant directions to keep, thus reducing the dimensionality of your problem. But it also means your new columns won't represent pure features anymore, but linear combinations of them.

If you keep all of the new columns, you won't reduce dimensionality; but your new features will be ordered in such a way that the first ones capture the most variance of your data.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.