Thursday, August 13, 2026
Home FEATURED Decision tree algorithm in data mining with example

Decision tree algorithm in data mining with example

A decision tree is a tree-like model used to make decisions based on feature values. It is a popular classification algorithm that is simple to understand and interpret.

Here is an example of how a decision tree works:

Suppose we have a dataset of customers, and we want to predict whether they will churn or not (i.e., leave the company). The dataset includes the following features: age, income, number of family members, and whether the customer has a mortgage.

To build a decision tree, we start at the root node and choose the feature that best splits the data into the churn and non-churn customers. For example, we might find that age is the most important predictor of churn, so we make age the root node.

Next, we split the data into two branches based on the possible values of the age. For example, we might split the data into customers who are under 30 and customers who are 30 or older.

We then repeat this process for each branch, choosing the feature that best splits the data into the churn and non-churn customers. For example, we might find that income is the most important predictor for customers under 30, and the number of family members is the most important predictor for customers 30 or older.

This process continues until we reach a leaf node, which represents the predicted class. For example, a leaf node might represent the prediction that a customer will churn or not churn.

Here is a graphical representation of the decision tree:

In this example, the decision tree is used to predict whether a customer will churn based on their age, income, and number of family members. The tree makes a prediction by starting at the root node (age) and following the branches until it reaches a leaf node, which represents the predicted class (churn or not churn).

Decision trees are simple to understand and interpret but can be prone to overfitting, especially if the tree is allowed to grow too deep. To prevent overfitting, we can prune the tree by removing branches that do not improve the accuracy of the model.

datasagarhttp://www.DataSagar.com
Sagar is multidisciplinary technologist, educator, and entrepreneur based in Nepal. As the founder of Illionso Technologies and Kashi Garden Resort, he operates at the intersection of web architecture, data intelligence, innovation, and digital transformation. From building digital solutions to scaling real-world concepts, his mission is to share knowledge alongside merge emerging as well as disruptive technologies with transformative offline experiences.
RELATED ARTICLES

Why Linux Won the Infrastructure War? Lessons from Linus Torvalds

In 1991, 21-year-old Linus Torvalds announced a "hobby" operating system. Today, Linux powers supercomputers, cloud servers, and Android. Explore his journey, the open-source economy, and the lessons for modern developers.

What Is Vibe Coding? A Complete Beginner’s Guide to Building Software and Web Pages With AI

A few years ago, building a website meant sitting down with a programming book, picking a language, and slowly working through syntax...

What is Answer Engine Optimization (AEO)? Getting Ready for AI Powered Search and Agentic Era Digital Marketing

Search is changing faster than it has in the last two decades. For years, businesses focused on ranking their websites on search...

Most Popular

Why Linux Won the Infrastructure War? Lessons from Linus Torvalds

In 1991, 21-year-old Linus Torvalds announced a "hobby" operating system. Today, Linux powers supercomputers, cloud servers, and Android. Explore his journey, the open-source economy, and the lessons for modern developers.

What Is Vibe Coding? A Complete Beginner’s Guide to Building Software and Web Pages With AI

A few years ago, building a website meant sitting down with a programming book, picking a language, and slowly working through syntax...

What is Answer Engine Optimization (AEO)? Getting Ready for AI Powered Search and Agentic Era Digital Marketing

Search is changing faster than it has in the last two decades. For years, businesses focused on ranking their websites on search...

The Plain Text Web: Why llms.txt Is Becoming the New Site Standard

The web built today is heavy. Between client-side JavaScript, cookie banners, tracker scripts, and responsive CSS grids, a typical webpage carries megabytes...