How many principal components should I choose for PCA?2019 Community Moderator ElectionHow do I use principal component analysis in supervised machine learning classification problems?Using Principal Component Analysis (PCA) for feature reduction (HOG-PCA)Principal component analysis and feature reductionsHow to use principal component analysis (PCA) to speed up detection?Correspondence between PCA principal components and the original variablesPrincipal Component Analysis in Python intrinsic dimension map to feature names?Using PCA on test set which has dimensionality less than number of principal componentsFinding original features' effect to the principal components used as inputs in Kernel PCAPCA analysis considering N-less relevant componentsHow to select components instead of projecting them?

How could a female member of a species produce eggs unto death?

What is this large pipe coming out of my roof?

Life insurance that covers only simultaneous/dual deaths

Why are there 40 737 Max planes in flight when they have been grounded as not airworthy?

Does this AnyDice function accurately calculate the number of ogres you make unconcious with three 4th-level castings of Sleep?

Making a sword in the stone, in a medieval world without magic

Did CPM support custom hardware using device drivers?

Does this property of comaximal ideals always holds?

Could the Saturn V actually have launched astronauts around Venus?

Calculus II Professor will not accept my correct integral evaluation that uses a different method, should I bring this up further?

Why doesn't the EU now just force the UK to choose between referendum and no-deal?

It's a yearly task, alright

What options are left, if Britain cannot decide?

Professor being mistaken for a grad student

Rejected in 4th interview round citing insufficient years of experience

What has been your most complicated TikZ drawing?

Employee lack of ownership

Will a pinhole camera work with instant film?

How to deal with taxi scam when on vacation?

How could a scammer know the apps on my phone / iTunes account?

Is it possible / allowed to upcast ritual spells?

How do I hide Chekhov's Gun?

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?

How to deal with a cynical class?



How many principal components should I choose for PCA?



2019 Community Moderator ElectionHow do I use principal component analysis in supervised machine learning classification problems?Using Principal Component Analysis (PCA) for feature reduction (HOG-PCA)Principal component analysis and feature reductionsHow to use principal component analysis (PCA) to speed up detection?Correspondence between PCA principal components and the original variablesPrincipal Component Analysis in Python intrinsic dimension map to feature names?Using PCA on test set which has dimensionality less than number of principal componentsFinding original features' effect to the principal components used as inputs in Kernel PCAPCA analysis considering N-less relevant componentsHow to select components instead of projecting them?










1















I have a dataframe with few categorical and numerical features. To that I've concatenated my BoW(CountVectorizer) of text column which resulted in more than 56,000 features. So I'm considering to do PCA for reducing number of features.



I think choosing correct number of principal components is crucial here but I'm confused on how many n_components to consider here?










share|improve this question



















  • 1





    Great question!

    – theantomc
    Mar 9 at 10:43















1















I have a dataframe with few categorical and numerical features. To that I've concatenated my BoW(CountVectorizer) of text column which resulted in more than 56,000 features. So I'm considering to do PCA for reducing number of features.



I think choosing correct number of principal components is crucial here but I'm confused on how many n_components to consider here?










share|improve this question



















  • 1





    Great question!

    – theantomc
    Mar 9 at 10:43













1












1








1








I have a dataframe with few categorical and numerical features. To that I've concatenated my BoW(CountVectorizer) of text column which resulted in more than 56,000 features. So I'm considering to do PCA for reducing number of features.



I think choosing correct number of principal components is crucial here but I'm confused on how many n_components to consider here?










share|improve this question
















I have a dataframe with few categorical and numerical features. To that I've concatenated my BoW(CountVectorizer) of text column which resulted in more than 56,000 features. So I'm considering to do PCA for reducing number of features.



I think choosing correct number of principal components is crucial here but I'm confused on how many n_components to consider here?







machine-learning nlp pca svd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 12:41







user214

















asked Mar 7 at 12:30









user214user214

461115




461115







  • 1





    Great question!

    – theantomc
    Mar 9 at 10:43












  • 1





    Great question!

    – theantomc
    Mar 9 at 10:43







1




1





Great question!

– theantomc
Mar 9 at 10:43





Great question!

– theantomc
Mar 9 at 10:43












1 Answer
1






active

oldest

votes


















3














You can plot a graph with the top k components and the variance of the k components.Choose k based on the variance contained in those components.95% or above would be ideal.






share|improve this answer























  • Yoshitha, I'm doing a two class classification task and I'm training my model using KNN. The time complexity of KNN is really high for high dimensional data. For 95% variance I may have to choose more number of components thereby increasing dimensions. Is it mandatory to select 95% for every scenario ?

    – user214
    Mar 7 at 13:18












  • It is not needed that you have 95%. Check the graph and you can select the k based on the steep of the curve. If there is sudden drop in the variance somewhere, choose k just before the sudden drop. On top of it, visualise the data and make sure that you capture enough information from data with the k components.

    – Yoshitha Penaganti
    Mar 8 at 6:06












  • can you check my variance plot. This is the image. What do you suggest here? How many components should I choose?

    – user214
    Mar 8 at 9:07






  • 1





    It seems like you have to take number of components atleast 500.

    – Yoshitha Penaganti
    Mar 8 at 11:23











  • I was also thinking the same. After 500 components increase in variance is less. I'll experiment and see. Thank you :)

    – user214
    Mar 8 at 11:33










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55043860%2fhow-many-principal-components-should-i-choose-for-pca%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














You can plot a graph with the top k components and the variance of the k components.Choose k based on the variance contained in those components.95% or above would be ideal.






share|improve this answer























  • Yoshitha, I'm doing a two class classification task and I'm training my model using KNN. The time complexity of KNN is really high for high dimensional data. For 95% variance I may have to choose more number of components thereby increasing dimensions. Is it mandatory to select 95% for every scenario ?

    – user214
    Mar 7 at 13:18












  • It is not needed that you have 95%. Check the graph and you can select the k based on the steep of the curve. If there is sudden drop in the variance somewhere, choose k just before the sudden drop. On top of it, visualise the data and make sure that you capture enough information from data with the k components.

    – Yoshitha Penaganti
    Mar 8 at 6:06












  • can you check my variance plot. This is the image. What do you suggest here? How many components should I choose?

    – user214
    Mar 8 at 9:07






  • 1





    It seems like you have to take number of components atleast 500.

    – Yoshitha Penaganti
    Mar 8 at 11:23











  • I was also thinking the same. After 500 components increase in variance is less. I'll experiment and see. Thank you :)

    – user214
    Mar 8 at 11:33















3














You can plot a graph with the top k components and the variance of the k components.Choose k based on the variance contained in those components.95% or above would be ideal.






share|improve this answer























  • Yoshitha, I'm doing a two class classification task and I'm training my model using KNN. The time complexity of KNN is really high for high dimensional data. For 95% variance I may have to choose more number of components thereby increasing dimensions. Is it mandatory to select 95% for every scenario ?

    – user214
    Mar 7 at 13:18












  • It is not needed that you have 95%. Check the graph and you can select the k based on the steep of the curve. If there is sudden drop in the variance somewhere, choose k just before the sudden drop. On top of it, visualise the data and make sure that you capture enough information from data with the k components.

    – Yoshitha Penaganti
    Mar 8 at 6:06












  • can you check my variance plot. This is the image. What do you suggest here? How many components should I choose?

    – user214
    Mar 8 at 9:07






  • 1





    It seems like you have to take number of components atleast 500.

    – Yoshitha Penaganti
    Mar 8 at 11:23











  • I was also thinking the same. After 500 components increase in variance is less. I'll experiment and see. Thank you :)

    – user214
    Mar 8 at 11:33













3












3








3







You can plot a graph with the top k components and the variance of the k components.Choose k based on the variance contained in those components.95% or above would be ideal.






share|improve this answer













You can plot a graph with the top k components and the variance of the k components.Choose k based on the variance contained in those components.95% or above would be ideal.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 7 at 12:45









Yoshitha PenagantiYoshitha Penaganti

24814




24814












  • Yoshitha, I'm doing a two class classification task and I'm training my model using KNN. The time complexity of KNN is really high for high dimensional data. For 95% variance I may have to choose more number of components thereby increasing dimensions. Is it mandatory to select 95% for every scenario ?

    – user214
    Mar 7 at 13:18












  • It is not needed that you have 95%. Check the graph and you can select the k based on the steep of the curve. If there is sudden drop in the variance somewhere, choose k just before the sudden drop. On top of it, visualise the data and make sure that you capture enough information from data with the k components.

    – Yoshitha Penaganti
    Mar 8 at 6:06












  • can you check my variance plot. This is the image. What do you suggest here? How many components should I choose?

    – user214
    Mar 8 at 9:07






  • 1





    It seems like you have to take number of components atleast 500.

    – Yoshitha Penaganti
    Mar 8 at 11:23











  • I was also thinking the same. After 500 components increase in variance is less. I'll experiment and see. Thank you :)

    – user214
    Mar 8 at 11:33

















  • Yoshitha, I'm doing a two class classification task and I'm training my model using KNN. The time complexity of KNN is really high for high dimensional data. For 95% variance I may have to choose more number of components thereby increasing dimensions. Is it mandatory to select 95% for every scenario ?

    – user214
    Mar 7 at 13:18












  • It is not needed that you have 95%. Check the graph and you can select the k based on the steep of the curve. If there is sudden drop in the variance somewhere, choose k just before the sudden drop. On top of it, visualise the data and make sure that you capture enough information from data with the k components.

    – Yoshitha Penaganti
    Mar 8 at 6:06












  • can you check my variance plot. This is the image. What do you suggest here? How many components should I choose?

    – user214
    Mar 8 at 9:07






  • 1





    It seems like you have to take number of components atleast 500.

    – Yoshitha Penaganti
    Mar 8 at 11:23











  • I was also thinking the same. After 500 components increase in variance is less. I'll experiment and see. Thank you :)

    – user214
    Mar 8 at 11:33
















Yoshitha, I'm doing a two class classification task and I'm training my model using KNN. The time complexity of KNN is really high for high dimensional data. For 95% variance I may have to choose more number of components thereby increasing dimensions. Is it mandatory to select 95% for every scenario ?

– user214
Mar 7 at 13:18






Yoshitha, I'm doing a two class classification task and I'm training my model using KNN. The time complexity of KNN is really high for high dimensional data. For 95% variance I may have to choose more number of components thereby increasing dimensions. Is it mandatory to select 95% for every scenario ?

– user214
Mar 7 at 13:18














It is not needed that you have 95%. Check the graph and you can select the k based on the steep of the curve. If there is sudden drop in the variance somewhere, choose k just before the sudden drop. On top of it, visualise the data and make sure that you capture enough information from data with the k components.

– Yoshitha Penaganti
Mar 8 at 6:06






It is not needed that you have 95%. Check the graph and you can select the k based on the steep of the curve. If there is sudden drop in the variance somewhere, choose k just before the sudden drop. On top of it, visualise the data and make sure that you capture enough information from data with the k components.

– Yoshitha Penaganti
Mar 8 at 6:06














can you check my variance plot. This is the image. What do you suggest here? How many components should I choose?

– user214
Mar 8 at 9:07





can you check my variance plot. This is the image. What do you suggest here? How many components should I choose?

– user214
Mar 8 at 9:07




1




1





It seems like you have to take number of components atleast 500.

– Yoshitha Penaganti
Mar 8 at 11:23





It seems like you have to take number of components atleast 500.

– Yoshitha Penaganti
Mar 8 at 11:23













I was also thinking the same. After 500 components increase in variance is less. I'll experiment and see. Thank you :)

– user214
Mar 8 at 11:33





I was also thinking the same. After 500 components increase in variance is less. I'll experiment and see. Thank you :)

– user214
Mar 8 at 11:33



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55043860%2fhow-many-principal-components-should-i-choose-for-pca%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived