Page 90 - Data Science Algorithms in a Week
P. 90

Random Forest


            When constructing a random decision tree as a part of a random forest, we will choose only
            a subset out of them in a random manner with replacement.



            Random forest construction

            We construct a random forest that will consist of two random decision trees.



            Construction of random decision tree number 0
            We are given six features as the input data. Out of these, we choose randomly six features
            with replacement for the construction of this random decision tree:

                [['None', 'Warm', 'No'], ['None', 'Warm', 'No'], ['Small', 'Cold', 'No'],
                ['Good', 'Cold', 'No'], ['Good', 'Cold', 'No'], ['Good', 'Cold', 'No']]
            We start the construction with the root node to create the first node of the tree. We would
            like to add children to the node [root].

            We have the following variables available ['swimming_suit', 'water_temperature'].
            As there are fewer of them than the parameter m=3, we consider all of them. Of these, the
            variable with the highest information gain is swimming suit.

            Therefore, we will branch the node further on this variable. We also remove this variable
            from the list of the available variables for the children of the current node. Using the
            variable swimming_suit, we partition the data in the current node as follows:

                      Partition for swimming_suit=Small: [['Small', 'Cold', 'No']]
                      Partition for swimming_suit=None: [['None', 'Warm', 'No'], ['None',
                      'Warm', 'No']]
                      Partition for swimming_suit=Good: [['Good', 'Cold', 'No'], ['Good',
                      'Cold', 'No'], ['Good', 'Cold', 'No']]

            Using the preceding partitions, we create the branches and the child nodes.
            We now add a child node [swimming_suit=Small] to the node [root]. This branch
            classifies one feature(s): [['Small', 'Cold', 'No']].

            We would like to add children to the node [swimming_suit=Small].







                                                     [ 78 ]
   85   86   87   88   89   90   91   92   93   94   95