How to handle columns with categorical data and many unique valuesdecision trees on mix of categorical and real value parametersPandas categorical variables encoding for regression (one-hot encoding vs dummy encoding)Imputation of missing values and dealing with categorical valuesHow to deal with categorical variablesOne hot encoding error “sort.list(y)…”One hot encoding vs Word embeddingHow to implement feature selection for categorical variables (especially with many categories)?ML Models: How to handle categorical feature with over 1000 unique values“Binary Encoding” in “Decision Tree” / “Random Forest” AlgorithmsDealing with multiple distinct-value categorical variables

Airbnb - host wants to reduce rooms, can we get refund?

In gnome-terminal only 2 out of 3 zoom keys work

Find the coordinate of two line segments that are perpendicular

How can I get precisely a certain cubic cm by changing the following factors?

Stark VS Thanos

Was it really necessary for the Lunar Module to have 2 stages?

Any examples of headwear for races with animal ears?

What does 「再々起」mean?

How to set the font color of quantity objects (Version 11.3 vs version 12)?

Sci-fi novel series with instant travel between planets through gates. A river runs through the gates

Pulling the rope with one hand is as heavy as with two hands?

If Earth is tilted, why is Polaris always above the same spot?

What's the polite way to say "I need to urinate"?

Pawn Sacrifice Justification

Is creating your own "experiment" considered cheating during a physics exam?

Single Colour Mastermind Problem

Is it possible to measure lightning discharges as Nikola Tesla?

Will tsunami waves travel forever if there was no land?

Transfer over $10k

Given what happens in Endgame, why doesn't Dormammu come back to attack the universe?

In the time of the mishna, were there Jewish cities without courts?

Do I have an "anti-research" personality?

Can fracking help reduce CO2?

How to determine the actual or "true" resolution of a digital photograph?



How to handle columns with categorical data and many unique values


decision trees on mix of categorical and real value parametersPandas categorical variables encoding for regression (one-hot encoding vs dummy encoding)Imputation of missing values and dealing with categorical valuesHow to deal with categorical variablesOne hot encoding error “sort.list(y)…”One hot encoding vs Word embeddingHow to implement feature selection for categorical variables (especially with many categories)?ML Models: How to handle categorical feature with over 1000 unique values“Binary Encoding” in “Decision Tree” / “Random Forest” AlgorithmsDealing with multiple distinct-value categorical variables













4












$begingroup$


I have a column with categorical data with nunique 3349 values, in a 18000k row dataset, which represent cities of the world.



I also have another column with 145 nunique values that I could also use in my model that represents product category.



Can I use one hot encoding to these columns or there's a problem with that solution?
Like which is the max number of unique values to use one hot encoding so there's not gonna be any problem ?



Can you point me to the right direction if I should use another encoding also?










share|improve this question









$endgroup$
















    4












    $begingroup$


    I have a column with categorical data with nunique 3349 values, in a 18000k row dataset, which represent cities of the world.



    I also have another column with 145 nunique values that I could also use in my model that represents product category.



    Can I use one hot encoding to these columns or there's a problem with that solution?
    Like which is the max number of unique values to use one hot encoding so there's not gonna be any problem ?



    Can you point me to the right direction if I should use another encoding also?










    share|improve this question









    $endgroup$














      4












      4








      4


      1



      $begingroup$


      I have a column with categorical data with nunique 3349 values, in a 18000k row dataset, which represent cities of the world.



      I also have another column with 145 nunique values that I could also use in my model that represents product category.



      Can I use one hot encoding to these columns or there's a problem with that solution?
      Like which is the max number of unique values to use one hot encoding so there's not gonna be any problem ?



      Can you point me to the right direction if I should use another encoding also?










      share|improve this question









      $endgroup$




      I have a column with categorical data with nunique 3349 values, in a 18000k row dataset, which represent cities of the world.



      I also have another column with 145 nunique values that I could also use in my model that represents product category.



      Can I use one hot encoding to these columns or there's a problem with that solution?
      Like which is the max number of unique values to use one hot encoding so there's not gonna be any problem ?



      Can you point me to the right direction if I should use another encoding also?







      machine-learning data categorical-data encoding






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 8 at 11:04









      dungeondungeon

      395




      395




















          1 Answer
          1






          active

          oldest

          votes


















          5












          $begingroup$

          For categorical columns, you have two options :



          1. Entity Embeddings

          2. One Hot Vector

          For a column with 145 values, I would use one hot encoding and Embedding for ~3k values. This decision might change depending on overall number of features.



          Embeddings map feature values into a 1D vector so that model knows NYC, Paris, London are similar cities in one aspect (size) and very different in other aspects. So, instead of using ~3k column of features, model will have ~50 columns of vector representation.



          Articles that explain Embeddings :



          • An Overview of Categorical Input Handling for Neural Networks


          • On learning embeddings for categorical data using Keras


          • Google Developers > Machine Learning > Embeddings: Categorical Input Data


          • Exploring Embeddings for Categorical Variables with Keras by Florian Teschner






          share|improve this answer











          $endgroup$













            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "557"
            ;
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2fdatascience.stackexchange.com%2fquestions%2f48875%2fhow-to-handle-columns-with-categorical-data-and-many-unique-values%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









            5












            $begingroup$

            For categorical columns, you have two options :



            1. Entity Embeddings

            2. One Hot Vector

            For a column with 145 values, I would use one hot encoding and Embedding for ~3k values. This decision might change depending on overall number of features.



            Embeddings map feature values into a 1D vector so that model knows NYC, Paris, London are similar cities in one aspect (size) and very different in other aspects. So, instead of using ~3k column of features, model will have ~50 columns of vector representation.



            Articles that explain Embeddings :



            • An Overview of Categorical Input Handling for Neural Networks


            • On learning embeddings for categorical data using Keras


            • Google Developers > Machine Learning > Embeddings: Categorical Input Data


            • Exploring Embeddings for Categorical Variables with Keras by Florian Teschner






            share|improve this answer











            $endgroup$

















              5












              $begingroup$

              For categorical columns, you have two options :



              1. Entity Embeddings

              2. One Hot Vector

              For a column with 145 values, I would use one hot encoding and Embedding for ~3k values. This decision might change depending on overall number of features.



              Embeddings map feature values into a 1D vector so that model knows NYC, Paris, London are similar cities in one aspect (size) and very different in other aspects. So, instead of using ~3k column of features, model will have ~50 columns of vector representation.



              Articles that explain Embeddings :



              • An Overview of Categorical Input Handling for Neural Networks


              • On learning embeddings for categorical data using Keras


              • Google Developers > Machine Learning > Embeddings: Categorical Input Data


              • Exploring Embeddings for Categorical Variables with Keras by Florian Teschner






              share|improve this answer











              $endgroup$















                5












                5








                5





                $begingroup$

                For categorical columns, you have two options :



                1. Entity Embeddings

                2. One Hot Vector

                For a column with 145 values, I would use one hot encoding and Embedding for ~3k values. This decision might change depending on overall number of features.



                Embeddings map feature values into a 1D vector so that model knows NYC, Paris, London are similar cities in one aspect (size) and very different in other aspects. So, instead of using ~3k column of features, model will have ~50 columns of vector representation.



                Articles that explain Embeddings :



                • An Overview of Categorical Input Handling for Neural Networks


                • On learning embeddings for categorical data using Keras


                • Google Developers > Machine Learning > Embeddings: Categorical Input Data


                • Exploring Embeddings for Categorical Variables with Keras by Florian Teschner






                share|improve this answer











                $endgroup$



                For categorical columns, you have two options :



                1. Entity Embeddings

                2. One Hot Vector

                For a column with 145 values, I would use one hot encoding and Embedding for ~3k values. This decision might change depending on overall number of features.



                Embeddings map feature values into a 1D vector so that model knows NYC, Paris, London are similar cities in one aspect (size) and very different in other aspects. So, instead of using ~3k column of features, model will have ~50 columns of vector representation.



                Articles that explain Embeddings :



                • An Overview of Categorical Input Handling for Neural Networks


                • On learning embeddings for categorical data using Keras


                • Google Developers > Machine Learning > Embeddings: Categorical Input Data


                • Exploring Embeddings for Categorical Variables with Keras by Florian Teschner







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 8 at 15:10

























                answered Apr 8 at 12:05









                Shamit VermaShamit Verma

                1,6891414




                1,6891414



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Data Science Stack Exchange!


                    • 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.

                    Use MathJax to format equations. MathJax reference.


                    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%2fdatascience.stackexchange.com%2fquestions%2f48875%2fhow-to-handle-columns-with-categorical-data-and-many-unique-values%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

                    Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

                    Tähtien Talli Jäsenet | Lähteet | NavigointivalikkoSuomen Hippos – Tähtien Talli

                    Do these cracks on my tires look bad? The Next CEO of Stack OverflowDry rot tire should I replace?Having to replace tiresFishtailed so easily? Bad tires? ABS?Filling the tires with something other than air, to avoid puncture hassles?Used Michelin tires safe to install?Do these tyre cracks necessitate replacement?Rumbling noise: tires or mechanicalIs it possible to fix noisy feathered tires?Are bad winter tires still better than summer tires in winter?Torque converter failure - Related to replacing only 2 tires?Why use snow tires on all 4 wheels on 2-wheel-drive cars?