Page 100 - Data Science Algorithms in a Week
P. 100
Random Forest
When constructing a random decision tree as a part of a random forest, we will choose only
a subset of them in a random way with replacement.
Random forest construction
We construct a random forest that will consist of four random decision trees.
Construction of a random decision tree number 0:
We are given 10 features as the input data. Out of these, we choose randomly 10 features
with replacement that we will use for the construction of this random decision tree:
[['Warm', 'Strong', 'Cloudy', 'No'], ['Cold', 'Breeze', 'Cloudy', 'No'],
['Cold', 'None', 'Sunny', 'Yes'], ['Cold', 'Breeze', 'Cloudy', 'No'],
['Hot', 'Breeze', 'Cloudy', 'Yes'], ['Warm', 'Strong', 'Cloudy', 'No'],
['Hot', 'Breeze', 'Cloudy', 'Yes'], ['Hot', 'Breeze', 'Cloudy', 'Yes'],
['Cold', 'Breeze', 'Cloudy', 'No'], ['Warm', 'Breeze', 'Sunny', 'Yes']]
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 ['Temperature', 'Wind', 'Sunshine']. As
there are fewer of them than the parameter m=4, we consider all of them. Of these, the
variable with the highest information gain is the variable 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 Temperature, we
partition the data in the current node as follows:
Partition for Temperature=Cold: [['Cold', 'Breeze', 'Cloudy',
'No'], ['Cold', 'None', 'Sunny', 'Yes'], ['Cold', 'Breeze',
'Cloudy', 'No'], ['Cold', 'Breeze', 'Cloudy', 'No']]
Partition for Temperature=Warm: [['Warm', 'Strong', 'Cloudy',
'No'], ['Warm', 'Strong', 'Cloudy', 'No'], ['Warm', 'Breeze',
'Sunny', 'Yes']]
Partition for Temperature=Hot: [['Hot', 'Breeze', 'Cloudy', 'Yes'],
['Hot', 'Breeze', 'Cloudy', 'Yes'], ['Hot', 'Breeze', 'Cloudy',
'Yes']]
[ 88 ]