You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Take a dataset with 50 features where only 5 are informative (generate one with sklearn.datasets.make_classification). Apply PCA and check whether the explained variance curve correctly identifies that the data is effectively 5-dimensional.
I ran PCA on a synthetic dataset created with sklearn.datasets.make_classification using:
n_samples = 5000
n_features = 50
n_informative = 5
Then I plotted the cumulative explained variance ratio from PCA.
What I observed
The curve increases smoothly and looks almost linear.
I do not see a clear elbow near 5 components.
I also tried sklearn PCA and got the same result, so the issue does not seem to be my PCA implementation.
What I want to ask
Why does the explained variance curve look so linear in this case?
Is it because:
n_informative = 5 only means 5 features are useful for predicting the label, not that the data is actually 5-dimensional in the PCA sense?
PCA measures variance, not label informativeness(only use X not y in my case)?
Are there ways to generate or transform the dataset so that PCA shows a clearer elbow near 5 components like different make_classification settings ?
If not, what method could I use to be able to find the number of informative features is 5 from the generated datasets?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
PCA Elbow Question
as the exercise quote:
I ran PCA on a synthetic dataset created with
sklearn.datasets.make_classificationusing:n_samples = 5000n_features = 50n_informative = 5Then I plotted the cumulative explained variance ratio from PCA.
What I observed
What I want to ask
Why does the explained variance curve look so linear in this case?
Is it because:
n_informative = 5only means 5 features are useful for predicting the label, not that the data is actually 5-dimensional in the PCA sense?Are there ways to generate or transform the dataset so that PCA shows a clearer elbow near 5 components like different
make_classificationsettings ?If not, what method could I use to be able to find the number of informative features is 5 from the generated datasets?
Current cumulative variance output
Code I ran using sklearn
All reactions