This Decision Tree in the Machine Learning tutorial will help you understand all the basics of the Decision Tree and how the Decision Tree algorithm works. In the end, we will implement a Decision Tree algorithm in Python on loan payment prediction. This Decision Tree tutorial is ideal for both beginners as well as professionals who want to learn Machine Learning Algorithms.
In this introduction to decision tree classification, I’ll walk you through the basics and demonstrate a number of applications.
A decision tree is a simple representation for classifying examples. It’s a form of supervised machine learning where we continuously split the data according to a certain parameter.
To understand the concept of decision trees, consider the above example. Let’s say you want to predict whether a person is fit or unfit, given their age, eating habits and physical activity. The decision nodes are the questions like “What’s the age?,” “Does the person exercise?,” “Does the person eat a lot of pizza?”
The leaves represent outcomes like fit or unfit.
What we’ve seen above is an example of a classification tree where the outcome was a variable like “fit” or “unfit.” Here the decision variable is categorical/discrete.
We build this kind of tree through a process known as binary recursive partitioning. This iterative process means we split the data into partitions and then split it up further on each of the branches.
Example of classification tree
Regression trees are decision trees wherein the target variable contains continuous values or real numbers (e.g., the price of a house, or a patient’s length of stay in a hospital).
Example of a regression tree
In this method, we break down a set of training examples into smaller and smaller subsets; this process incrementally develops an associated decision tree. At the end of the learning process, the algorithm returns a decision tree covering the training set.
The key is to use decision trees to partition the data space into clustered (or dense) regions and empty (or sparse) regions.
In decision tree classification, we classify a new example by submitting it to a series of tests that determine the example’s class label. These tests are organized in a hierarchical structure called a decision tree. Decision trees follow the divide and conquer algorithm.
We build decision trees using a heuristic called recursive partitioning. This approach is also commonly known as divide and conquer because it splits the data into subsets, which then split repeatedly into even smaller subsets, and so on and so forth. The process stops when the algorithm determines the data within the subsets are sufficiently homogenous or have met another stopping criterion.
Select a test for the root node. Create a branch for each possible outcome of the test.
Split instances into subsets, one for each branch extending from the node.
Repeat recursively for each branch, using only instances that reach the branch.
Stop recursion for a branch if all its instances have the same class.
Using the decision algorithm, we start at the tree root and split the data on the feature that results in the largest information gain (IG) (i.e., reduction in uncertainty towards the final decision).
In an iterative process, we can then repeat this splitting procedure at each child node until the leaves are pure. This means that the samples at each leaf node all belong to the same class.
In practice, we may set a limit on the tree’s depth to prevent overfitting. We compromise on purity here somewhat as the final leaves may still have some impurity.
Classifying whether an insect is a Grasshopper or a Katydid based on antenna length and abdomen length.
Biomedical Engineering: Decision trees identify features used in implantable devices.
Financial analysis: They measure customer satisfaction with a product or service.
Astronomy: Decision trees are to classify galaxies.
System Control: Decision trees have found their application in modern air conditioning and temperature controllers.
Manufacturing and production: Decision trees aid in quality control, semiconductor manufacturing, and more.
Healthcare: They help doctors diagnose patients in cardiology, psychiatry, and more.
Physics: Decision trees are used for particle detection.
#decisiontree #machinelearning #algorithm