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

Random Forest


            We have the following variable available ['water_temperature']. As there are fewer of
            them than the parameter m=3, we consider all of them. Out of these variables, the variable
            with the highest information gain is the variable water_temperature. 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 water
            temperature, we partition the data in the current node as follows:

                      Partition for water_temperature=Cold: [['Good', 'Cold', 'No']]
                      Partition for water_temperature=Warm: [['Good', 'Warm', 'Yes']]
            Now, given the partitions, let us create the branches and the child nodes.

            We add a child node [water_temperature=Cold] to the node [swimming_suit=Good].
            This branch classifies one feature(s): [['Good', 'Cold', 'No']]

            We do not have any available variables on which we could split the node further; therefore,
            we add a leaf node to the current branch of the tree. We add the leaf node [swim=No].

            We add a child node [water_temperature=Warm] to the node [swimming_suit=Good].
            This branch classifies one feature(s): [['Good', 'Warm', 'Yes']]
            We do not have any available variables on which we could split the node further; therefore,
            we add a leaf node to the current branch of the tree. We add the leaf node [swim=Yes].

            Now, we have added all the children nodes for the node [swimming_suit=Good].

            Now, we have added all the children nodes for the node [root].
            Therefore we have completed the construction of the random forest consisting of two
            random decision trees.

            Random forest graph:

                Tree 0:
                    Root
                    ├── [swimming_suit=Small]
                    │ └── [swim=No]
                    ├── [swimming_suit=None]
                    │ └── [swim=No]
                    └── [swimming_suit=Good]
                      └── [swim=No]
                Tree 1:
                    Root
                    ├── [swimming_suit=Small]
                    │ └── [swim=No]


                                                     [ 82 ]
   89   90   91   92   93   94   95   96   97   98   99