Construction of random decision tree number 1

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:

[['Good', 'Warm', 'Yes'], ['None', 'Warm', 'No'], ['Good', 'Cold', 'No'], ['None', 'Cold', 'No'], ['None', 'Warm', 'No'], ['Small', 'Warm', 'No']]

The rest of the construction of random decision tree number 1 is similar to the construction of the previous random decision tree number 0. The only difference is that the tree is built with the different randomly generated subset (as seen above) of the initial data.

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 the variable 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', 'Warm', 'No']]
  • Partition for swimming_suit=None: [['None', 'Warm', 'No'], ['None', 'Cold', 'No'], ['None', 'Warm', 'No']]
  • Partition for swimming_suit=Good: [['Good', 'Warm', 'Yes'], ['Good', 'Cold', 'No']]

Now, given the partitions, let us create the branches and the child nodes. We add a child node [swimming_suit=Small] to the node [root]. This branch classifies one feature(s): [['Small', 'Warm', 'No']].

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

We have the following variable available ['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 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. For the chosen variable water_temperature, all the remaining features have the same value: Warm. So, we end the branch with a leaf node. We add the leaf node [swim=No].

We add a child node [swimming_suit=None] to the node [root]. This branch classifies three feature(s): [['None', 'Warm', 'No'], ['None', 'Cold', 'No'], ['None', 'Warm', 'No']].

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

We have the following variable available ['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 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: [['None', 'Cold', 'No']]
  • Partition for water_temperature=Warm: [['None', 'Warm', 'No'], ['None', 'Warm', 'No']] 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=None]. This branch classifies one feature(s): [['None', '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=None]. This branch classifies two feature(s): [['None', 'Warm', 'No'], ['None', 'Warm', '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].

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

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

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

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] ├── [swimming_suit=None] │ ├── [water_temperature=Cold] │ │ └── [swim=No] │ └──[water_temperature=Warm] │ └── [swim=No] └── [swimming_suit=Good] ├── [water_temperature=Cold] │ └── [swim=No] └── [water_temperature=Warm] └── [swim=Yes] The total number of trees in the random forest=2. The maximum number of the variables considered at the node is m=3.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset