Decision Trees
A decision tree is a popular classifier:
- nodes represent decisions
- arcs represent possible answers
- terminal nodes represent class labels
We can think of these are if-else statements. Rules can be used to query a relational database.
Link to original
Strengths and Limitations
| Strengths | Limitations |
|---|---|
| Can be easily interpreted | Classifiers can create complex trees that do not generalise well to new data (overfitting) |
| Can handle both categorical and numerical variables | Sensitive to even small changes in data |
| Shows the most important features in a data set | |
| Not sensitive to outliers or missing data |
Algorithms
There are a bunch of different algorithms we can use:
- Hunt’s Algorithm (earliest, basis for most existing algorithms)
- CART
- IDE3, C4.5
- SLIQ, SPRINT
Hunt’s Algorithm
Often known as rule induction, nodes are repeatedly split until all elements represented belong to one class. Nodes then become terminal nodes.
- Let the set of training data be .
- Put all into a single tree node; if some attributes are continuous-valued, make them discrete. For example, age ranges can be binned into categories (u18, 18-40, 41-65, ..)
- If all instances in are in the same class, then stop
- Split the next node by selecting an attribute from your list of attributes that best splits the objects in the node, and create a node.
- Split the node according to the values of .
- Stop if either of the following conditions is met otherwise continue with :
- This partition divides the data into subsets that belong to a single class and no other node needs splitting.
- There are no remaining attributes on which the sample can be further divided.

Determining best splits
Commonly used measures to determine the best split include: GINI index, entropy (information theory)
We want to take a greedy approach that gives us homogeneous, pure classes.
- In a 2-class situation with 10 records, we split using attribute X and 10 records go to Class0 and 0 to Class1. This has 0 impurity and is ideal.
- If we split by X and half the records go to Class0 and the other to Class1, then we have an impurity of 0.5 which is the worst.
We need to determine a good measure of node impurity.
Gini Ratio
Gini Ratio
The Gini Ratio (Gini Impurity) is a measure of statistical dispersion, i.e. a measure of inequality (probability of this classification mislabelling a randomly selected example):
Where is the number of classes.
Link to original
Example Gini Ratios
![]() | ![]() | ![]() |
|---|---|---|
GINI Split
GINI Split
We use the GINI Split to find which variable to split on, we use the attribute with the lowest index according to the following formula:
Link to original
- Where is the occurrences of
- Where is total number of entries
Example Best Split




