Choosing the first node in a decision tree, basic example2019 Community Moderator ElectionQuestion on decision tree in the book Programming Collective IntelligenceDecision Tree EnsemblingIs it acceptable to select a random child node when using a Decision Tree (trained via ID3) to predict if an unknown attribute value is encounteredWhy is my classification tree is showing only one node, and how to resolve this issue?Decision tree orderingHow are boosted decision stumps different from a decision tree?Do C 4.5 or C 5.0 perform multi way split or binary split?Decision Tree: Efficient splitting of nodes, minimize number of gini evaluationsDecision Trees How to Calculate Entropy Gain for Continuous Values for split point?

Can a planet have a different gravitational pull depending on its location in orbit around its sun?

Is "plugging out" electronic devices an American expression?

Are objects structures and/or vice versa?

How to move the player while also allowing forces to affect it

How can I plot a Farey diagram?

What does 'script /dev/null' do?

Unbreakable Formation vs. Cry of the Carnarium

What to wear for invited talk in Canada

New order #4: World

Typesetting a double Over Dot on top of a symbol

Why do we use polarized capacitors?

Is there a way to make member function NOT callable from constructor?

Can I legally use front facing blue light in the UK?

Is this food a bread or a loaf?

What causes the sudden spool-up sound from an F-16 when enabling afterburner?

Domain expired, GoDaddy holds it and is asking more money

Symmetry in quantum mechanics

aging parents with no investments

"My colleague's body is amazing"

Filling an area between two curves

What is the meaning of "of trouble" in the following sentence?

Is Social Media Science Fiction?

How can I fix this gap between bookcases I made?

LWC and complex parameters



Choosing the first node in a decision tree, basic example



2019 Community Moderator ElectionQuestion on decision tree in the book Programming Collective IntelligenceDecision Tree EnsemblingIs it acceptable to select a random child node when using a Decision Tree (trained via ID3) to predict if an unknown attribute value is encounteredWhy is my classification tree is showing only one node, and how to resolve this issue?Decision tree orderingHow are boosted decision stumps different from a decision tree?Do C 4.5 or C 5.0 perform multi way split or binary split?Decision Tree: Efficient splitting of nodes, minimize number of gini evaluationsDecision Trees How to Calculate Entropy Gain for Continuous Values for split point?










1












$begingroup$


I'm wondering whether I'm understanding the process of choosing a node correctly and would like to see if this example makes sense.
using the following data :



> df
Y A B C
1 1 0 1 1
2 0 0 0 1
3 1 1 1 0
4 1 0 1 0
5 1 1 0 1
6 1 0 0 1


I will split the data on A,B,C and evaluate the entropy of each split, where the entropy is computed using



$$
p ; log_2(p) + (1-p); log_2(1-p)
$$



where $p$ is the proportion of successes for a particular split.



When splitting on A I have



 Y A B C
3 1 1 1 0
5 1 1 0 1


and



 Y A B C
1 1 0 1 1
2 0 0 0 1
4 1 0 1 0
6 1 0 0 1


For $A = 1$ (the first data table) I have $p = 1$, then entropy is 0.



for $A=0$ (second table) I have $p=0.75$ and entropy 0.81



So for splitting on $A$ I would state that the entropy is



$$
0 + 0.81 = 0.81
$$



This is then carried out in a similar manner for $B,C$.



For $B=1$ I find $p=1$ so entropy = 1



For $B=0$ I find $p=0.66$ so entropy = 0.91



Then the entropy for splitting on $B$ is



$$
0 + 0.91 = 0.91
$$



For $C=1$ I find $p=0.75$ so entropy = 0.81



For $C=0$ I find $p=1$ so entropy = 0



Then the entropy for splitting on $C$ is



$$
0.81 + 0 = 0.81
$$



Given the above the split which has the highest entropy is $B$, therefore I would choose to split on $B$ first.



I now have a decision tree with one node, and need to select the next node for each branch of $B = 1$ and $B=0$.



This selection is carried out in the same manner as the above.



Is the computation and reasoning in the above valid?










share|improve this question









$endgroup$
















    1












    $begingroup$


    I'm wondering whether I'm understanding the process of choosing a node correctly and would like to see if this example makes sense.
    using the following data :



    > df
    Y A B C
    1 1 0 1 1
    2 0 0 0 1
    3 1 1 1 0
    4 1 0 1 0
    5 1 1 0 1
    6 1 0 0 1


    I will split the data on A,B,C and evaluate the entropy of each split, where the entropy is computed using



    $$
    p ; log_2(p) + (1-p); log_2(1-p)
    $$



    where $p$ is the proportion of successes for a particular split.



    When splitting on A I have



     Y A B C
    3 1 1 1 0
    5 1 1 0 1


    and



     Y A B C
    1 1 0 1 1
    2 0 0 0 1
    4 1 0 1 0
    6 1 0 0 1


    For $A = 1$ (the first data table) I have $p = 1$, then entropy is 0.



    for $A=0$ (second table) I have $p=0.75$ and entropy 0.81



    So for splitting on $A$ I would state that the entropy is



    $$
    0 + 0.81 = 0.81
    $$



    This is then carried out in a similar manner for $B,C$.



    For $B=1$ I find $p=1$ so entropy = 1



    For $B=0$ I find $p=0.66$ so entropy = 0.91



    Then the entropy for splitting on $B$ is



    $$
    0 + 0.91 = 0.91
    $$



    For $C=1$ I find $p=0.75$ so entropy = 0.81



    For $C=0$ I find $p=1$ so entropy = 0



    Then the entropy for splitting on $C$ is



    $$
    0.81 + 0 = 0.81
    $$



    Given the above the split which has the highest entropy is $B$, therefore I would choose to split on $B$ first.



    I now have a decision tree with one node, and need to select the next node for each branch of $B = 1$ and $B=0$.



    This selection is carried out in the same manner as the above.



    Is the computation and reasoning in the above valid?










    share|improve this question









    $endgroup$














      1












      1








      1





      $begingroup$


      I'm wondering whether I'm understanding the process of choosing a node correctly and would like to see if this example makes sense.
      using the following data :



      > df
      Y A B C
      1 1 0 1 1
      2 0 0 0 1
      3 1 1 1 0
      4 1 0 1 0
      5 1 1 0 1
      6 1 0 0 1


      I will split the data on A,B,C and evaluate the entropy of each split, where the entropy is computed using



      $$
      p ; log_2(p) + (1-p); log_2(1-p)
      $$



      where $p$ is the proportion of successes for a particular split.



      When splitting on A I have



       Y A B C
      3 1 1 1 0
      5 1 1 0 1


      and



       Y A B C
      1 1 0 1 1
      2 0 0 0 1
      4 1 0 1 0
      6 1 0 0 1


      For $A = 1$ (the first data table) I have $p = 1$, then entropy is 0.



      for $A=0$ (second table) I have $p=0.75$ and entropy 0.81



      So for splitting on $A$ I would state that the entropy is



      $$
      0 + 0.81 = 0.81
      $$



      This is then carried out in a similar manner for $B,C$.



      For $B=1$ I find $p=1$ so entropy = 1



      For $B=0$ I find $p=0.66$ so entropy = 0.91



      Then the entropy for splitting on $B$ is



      $$
      0 + 0.91 = 0.91
      $$



      For $C=1$ I find $p=0.75$ so entropy = 0.81



      For $C=0$ I find $p=1$ so entropy = 0



      Then the entropy for splitting on $C$ is



      $$
      0.81 + 0 = 0.81
      $$



      Given the above the split which has the highest entropy is $B$, therefore I would choose to split on $B$ first.



      I now have a decision tree with one node, and need to select the next node for each branch of $B = 1$ and $B=0$.



      This selection is carried out in the same manner as the above.



      Is the computation and reasoning in the above valid?










      share|improve this question









      $endgroup$




      I'm wondering whether I'm understanding the process of choosing a node correctly and would like to see if this example makes sense.
      using the following data :



      > df
      Y A B C
      1 1 0 1 1
      2 0 0 0 1
      3 1 1 1 0
      4 1 0 1 0
      5 1 1 0 1
      6 1 0 0 1


      I will split the data on A,B,C and evaluate the entropy of each split, where the entropy is computed using



      $$
      p ; log_2(p) + (1-p); log_2(1-p)
      $$



      where $p$ is the proportion of successes for a particular split.



      When splitting on A I have



       Y A B C
      3 1 1 1 0
      5 1 1 0 1


      and



       Y A B C
      1 1 0 1 1
      2 0 0 0 1
      4 1 0 1 0
      6 1 0 0 1


      For $A = 1$ (the first data table) I have $p = 1$, then entropy is 0.



      for $A=0$ (second table) I have $p=0.75$ and entropy 0.81



      So for splitting on $A$ I would state that the entropy is



      $$
      0 + 0.81 = 0.81
      $$



      This is then carried out in a similar manner for $B,C$.



      For $B=1$ I find $p=1$ so entropy = 1



      For $B=0$ I find $p=0.66$ so entropy = 0.91



      Then the entropy for splitting on $B$ is



      $$
      0 + 0.91 = 0.91
      $$



      For $C=1$ I find $p=0.75$ so entropy = 0.81



      For $C=0$ I find $p=1$ so entropy = 0



      Then the entropy for splitting on $C$ is



      $$
      0.81 + 0 = 0.81
      $$



      Given the above the split which has the highest entropy is $B$, therefore I would choose to split on $B$ first.



      I now have a decision tree with one node, and need to select the next node for each branch of $B = 1$ and $B=0$.



      This selection is carried out in the same manner as the above.



      Is the computation and reasoning in the above valid?







      machine-learning decision-trees information-theory






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 29 at 10:37









      baxxbaxx

      1314




      1314




















          1 Answer
          1






          active

          oldest

          votes


















          1












          $begingroup$

          Some corrections in the above:



          • While calculating entropy of a split, you should take into account the weights - fraction of instances in each branch:

          $$
          entropy(A) = 0 * (2/6) + 0.81 * (4/6) = 0.54\
          entropy(B) = 0 * (3/6) + 0.91 * (3/6) = 0.45\
          entropy(C) = 0 * (2/6) + 0.81 * (4/6) = 0.54
          $$



          • While choosing an attribute to split, you should choose the one with lowest entropy after the split. Entropy is the uncertainty, so you want to minimise it. As an example, if the split was perfect (all 0's on one side, and all 1's on the other), then entropy will be 0.

          After selection of one node, the tree is built out recursively, as you mention.






          share|improve this answer









          $endgroup$













            Your Answer





            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            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%2f48208%2fchoosing-the-first-node-in-a-decision-tree-basic-example%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









            1












            $begingroup$

            Some corrections in the above:



            • While calculating entropy of a split, you should take into account the weights - fraction of instances in each branch:

            $$
            entropy(A) = 0 * (2/6) + 0.81 * (4/6) = 0.54\
            entropy(B) = 0 * (3/6) + 0.91 * (3/6) = 0.45\
            entropy(C) = 0 * (2/6) + 0.81 * (4/6) = 0.54
            $$



            • While choosing an attribute to split, you should choose the one with lowest entropy after the split. Entropy is the uncertainty, so you want to minimise it. As an example, if the split was perfect (all 0's on one side, and all 1's on the other), then entropy will be 0.

            After selection of one node, the tree is built out recursively, as you mention.






            share|improve this answer









            $endgroup$

















              1












              $begingroup$

              Some corrections in the above:



              • While calculating entropy of a split, you should take into account the weights - fraction of instances in each branch:

              $$
              entropy(A) = 0 * (2/6) + 0.81 * (4/6) = 0.54\
              entropy(B) = 0 * (3/6) + 0.91 * (3/6) = 0.45\
              entropy(C) = 0 * (2/6) + 0.81 * (4/6) = 0.54
              $$



              • While choosing an attribute to split, you should choose the one with lowest entropy after the split. Entropy is the uncertainty, so you want to minimise it. As an example, if the split was perfect (all 0's on one side, and all 1's on the other), then entropy will be 0.

              After selection of one node, the tree is built out recursively, as you mention.






              share|improve this answer









              $endgroup$















                1












                1








                1





                $begingroup$

                Some corrections in the above:



                • While calculating entropy of a split, you should take into account the weights - fraction of instances in each branch:

                $$
                entropy(A) = 0 * (2/6) + 0.81 * (4/6) = 0.54\
                entropy(B) = 0 * (3/6) + 0.91 * (3/6) = 0.45\
                entropy(C) = 0 * (2/6) + 0.81 * (4/6) = 0.54
                $$



                • While choosing an attribute to split, you should choose the one with lowest entropy after the split. Entropy is the uncertainty, so you want to minimise it. As an example, if the split was perfect (all 0's on one side, and all 1's on the other), then entropy will be 0.

                After selection of one node, the tree is built out recursively, as you mention.






                share|improve this answer









                $endgroup$



                Some corrections in the above:



                • While calculating entropy of a split, you should take into account the weights - fraction of instances in each branch:

                $$
                entropy(A) = 0 * (2/6) + 0.81 * (4/6) = 0.54\
                entropy(B) = 0 * (3/6) + 0.91 * (3/6) = 0.45\
                entropy(C) = 0 * (2/6) + 0.81 * (4/6) = 0.54
                $$



                • While choosing an attribute to split, you should choose the one with lowest entropy after the split. Entropy is the uncertainty, so you want to minimise it. As an example, if the split was perfect (all 0's on one side, and all 1's on the other), then entropy will be 0.

                After selection of one node, the tree is built out recursively, as you mention.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 29 at 14:23









                raghuraghu

                45633




                45633



























                    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%2f48208%2fchoosing-the-first-node-in-a-decision-tree-basic-example%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

                    Marja Vauras Lähteet | Aiheesta muualla | NavigointivalikkoMarja Vauras Turun yliopiston tutkimusportaalissaInfobox OKSuomalaisen Tiedeakatemian varsinaiset jäsenetKasvatustieteiden tiedekunnan dekaanit ja muu johtoMarja VaurasKoulutusvienti on kestävyys- ja ketteryyslaji (2.5.2017)laajentamallaWorldCat Identities0000 0001 0855 9405n86069603utb201588738523620927

                    Which is better: GPT or RelGAN for text generation?2019 Community Moderator ElectionWhat is the difference between TextGAN and LM for text generation?GANs (generative adversarial networks) possible for text as well?Generator loss not decreasing- text to image synthesisChoosing a right algorithm for template-based text generationHow should I format input and output for text generation with LSTMsGumbel Softmax vs Vanilla Softmax for GAN trainingWhich neural network to choose for classification from text/speech?NLP text autoencoder that generates text in poetic meterWhat is the interpretation of the expectation notation in the GAN formulation?What is the difference between TextGAN and LM for text generation?How to prepare the data for text generation task

                    Is this part of the description of the Archfey warlock's Misty Escape feature redundant?When is entropic ward considered “used”?How does the reaction timing work for Wrath of the Storm? Can it potentially prevent the damage from the triggering attack?Does the Dark Arts Archlich warlock patrons's Arcane Invisibility activate every time you cast a level 1+ spell?When attacking while invisible, when exactly does invisibility break?Can I cast Hellish Rebuke on my turn?Do I have to “pre-cast” a reaction spell in order for it to be triggered?What happens if a Player Misty Escapes into an Invisible CreatureCan a reaction interrupt multiattack?Does the Fiend-patron warlock's Hurl Through Hell feature dispel effects that require the target to be on the same plane as the caster?What are you allowed to do while using the Warlock's Eldritch Master feature?