Have a nice day. Please help me. I have a normalized file. This file consists of 21 numeric columns.
I will apply pca analysis
to this file as below :
pca = decomposition.PCA(n_components=21)
pca_output = pca.fit_transform(pca_matrix)
pca_inverse = pca.inverse_transform(pca_output)
As far as I understand, the value I assign to the n_components
variable is equal to the number of columns. But what I do not understand is how do I determine the n_components
variable.
It is a hyperparameter and finding its optimal value depends on what you want to do with your data. Let me describe 3 possible uses:
n_components=None
). Then inspect the attribute explained_variance_ratio_
and decide how many you are willing to drop. Or you can put n_components='mle'
and let the data decide for you. n_components
and the predictive model's hyperparameters.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.