# Using Target Variable to perform Principal Component Analysis in R

#1

This article presents the technique to incorporate the predictor variable while performing Principal Component Analysis and how it can significantly reduce the number of Principal Components while still capturing the maximum variance.

You can read the article in detail over here.

Neeraj

#2

Hi everybody,
I want to add a question on this particular topic (PCA). How can we choose the right number of components after performing PCA on a data set in Python?

#3

@ravi_6767,
For choosing right number of Principal Components(PCs) you can see the amount of variance each PC explains :
`# as variance decreases importance of that particular PC decreases var= pca.explained_variance_ratio_`

or you can check cumulative variance of Principal Components :
`# as the plot saturates PC's significance is minimal plt.plot(np.cumsum(np.round(pca.explained_variance_ratio_, decimals=4)*100))`

For better understanding you can go through this article on AV :

Regards,
Danish

pinned globally #4

#5

I don’t know about the python but PCA with regression and choosing components that help in predictive power is a fairly old concept. And with R there’s “pcr” from the “pls” package. https://cran.r-project.org/web/packages/pls/pls.pdf.