Building a Classification Tree

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

../../_images/animal_dataset.png

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.

../../_images/ctree_1.png

Let’s make another decision. This time the decision has allowed us to separate the rabbits out.

../../_images/ctree_2.png

We just need to make one final decision.

../../_images/ctree_3.png

This is what our final classification tree looks like:

../../_images/ctree_4.png