3.2. Building a Classification Tree#
The purpose of a classification tree is to predict a class for a given piece of input data. Consider the following training data:
Weight (kg) |
Tail Length (cm) |
Ear Length (cm) |
Class |
|---|---|---|---|
2.2 |
4 |
8 |
rabbit |
4 |
28 |
5 |
cat |
3 |
26 |
4 |
cat |
35 |
32 |
9 |
dog |
2 |
3 |
7 |
rabbit |
3.5 |
16 |
7 |
dog |
Our goal is to build a classification tree that can be used to separate out the 3 classes: rabbit, cat, dog.
Let’s make a decision. This decision has allowed us to separate out the large dog from the rest of our dataset.
Let’s make another decision. This time the decision has allowed us to separate the rabbits out.
We just need to make one final decision.
This is what our final classification tree looks like: