Page 105 - Data Science Algorithms in a Week
P. 105
Random Forest
Tree 3:
Root
├── [Temperature=Cold]
│ └── [Play=No]
├── [Temperature=Warm]
│ ├──[Wind=Strong]
│ │ └──[Play=No]
│ ├── [Wind=None]
│ │ └── [Play=Yes]
│ └──[Wind=Breeze]
│ └── [Play=Yes]
└── [Temperature=Hot]
├── [Wind=Strong]
│ └── [Play=Yes]
└── [Wind=Breeze]
└── [Play=Yes]
The total number of trees in the random forest=4.
The maximum number of the variables considered at the node is m=4.
Classification:
Given the constructed random forest we classify feature ['Warm', 'Strong', 'Sunny',
'?']:
Tree 0 votes for the class: No
Tree 1 votes for the class: No
Tree 2 votes for the class: No
Tree 3 votes for the class: No
The class with the maximum number of votes is 'No'. Thus the constructed random forest
classifies the feature ['Warm', 'Strong', 'Sunny', '?'] into the class 'No'.
Input:
To perform the preceding analysis, we use a program implemented earlier in this chapter.
First we put the data from the table into the following CSV file:
# source_code/4/chess.csv
Temperature,Wind,Sunshine,Play
Cold,Strong,Cloudy,No
Warm,Strong,Cloudy,No
Warm,None,Sunny,Yes
Hot,None,Sunny,No
Hot,Breeze,Cloudy,Yes
Warm,Breeze,Sunny,Yes
Cold,Breeze,Cloudy,No
[ 93 ]