This lesson is being piloted (Beta version)

Introduction to Machine Learning using Python: Detailed explanation on Decision Tree

Decision Tree

Splitting algorithm

Example on Decision Tree

Assume we have a sample data of 30 students in the training set with three input variables Gender (Boy/ Girl), Class( IX/ X) and Height (5 to 6 ft); one output variable: Play_Cricket (binary)

image

This is a typical problem for Decision Tree algorithm

Next we gonna use different splitting algorithm to split the nodes:

Gini Impurity

image

As there are 3 input variables (Gender, Class, Height), the algorithm will be splitting for all variables and calculate the Gini Impurity correspondingly based on the above formulation:

Splitting based on Gender:

image

Similarly, splitting based on Height:

image

Splitting based on Class:

image

Base on the 3 Gini Impurity on the splitting, we go with the smallest values, which is splitting by Gender.

The process is continue with the next nodes with other variables.

Chi-Squared

image

Entropy

image