Sitemap
Bismaashraf

Bismaashraf

Decision Tree

3 min readJul 22, 2026

--

What is a Decision Tree?

A Decision Tree is a supervised learning technique used for both classification and regression problems. It works by repeatedly dividing a dataset into smaller groups based on different input features until a final prediction can be made.

In simple words, a Decision Tree learns a set of if then rules from historical data and uses these rules to predict outcomes for new data

Real-World Example: Loan Approval System

Consider a bank that wants to determine whether a customer should receive a loan.

The decision-making process might look like this:

Is the applicant’s credit score greater than 700?

  • No → Reject the application.
  • Yes → Evaluate annual income.

Is the annual income above $50,000?

  • Yes → Approve the loan.
  • No → Check employment status.

Is the applicant employed full-time?

  • Yes → Approve the loan.
  • No → Reject the application.
Press enter or click to view image in full size

Structure of a Decision Tree

A Decision Tree consists of several important components.

1. Root Node

The Root Node is the starting point of the tree. It contains the complete dataset and performs the first split based on the most informative feature.

Example:
“Is the credit score above 700?”

2. Decision Node

Decision Nodes, also called internal nodes, represent additional conditions that further divide the data.

Example:
“Is annual income greater than $50,000?”

3. Branch

Branches connect nodes and represent the outcomes of decisions.

Examples:

  • Yes
  • No

4. Leaf Node

Leaf Nodes are the final points of the tree where predictions are produced.

Get Bismaashraf’s stories in your inbox

Join Medium for free to get updates from this writer.

Examples:

  • Loan Approved
  • Loan Rejected
Press enter or click to view image in full size

How Does a Decision Tree Work?

A Decision Tree generally follows these steps:

  1. Begin with the complete dataset.
  2. Select the feature that best separates the data.
  3. Split the dataset into smaller subsets.
  4. Repeat the process for each subset.
  5. Stop when a stopping condition is achieved, such as:
  • All samples belong to the same class.
  • Maximum tree depth has been reached.
  • No further meaningful splits are possible.

The final model predicts new observations by moving from the root node to one of the leaf nodes.

Types of Decision Trees

1. Classification Tree

A Classification Tree predicts categorical outputs.

Examples:

  • Spam or Not Spam
  • Pass or Fail
  • Fraud or Genuine Transaction

2. Regression Tree

A Regression Tree predicts continuous numerical values.

Examples:

  • House Prices
  • Employee Salaries
  • Future Sales Revenue

Advantages

Decision Trees offer several benefits:

  • Easy to understand and interpret
  • Works with both numerical and categorical data
  • Requires little data preprocessing
  • Handles non-linear relationships effectively

Limitations

  • Can overfit the training data
  • Sensitive to small changes in data
  • Large trees become difficult to interpret
  • May be less accurate than ensemble methods like Random Forests

Applications

  • Healthcare: Disease prediction and diagnosis
  • Finance: Loan approval and risk analysis
  • Marketing: Customer segmentation
  • Retail: Sales and product recommendations
  • Fraud Detection: Identifying suspicious activities
  • Education: Predicting student performance

Conclusion

Decision Trees are simple yet powerful machine learning algorithms that mimic human decision-making by using a series of conditions and rules. Their easy to understand structure makes them highly suitable for solving both classification and regression problems. Although they may suffer from issues such as overfitting and sensitivity to data changes, these limitations can be reduced through proper tuning techniques. Due to their interpretability, flexibility, and wide range of practical applications, Decision Trees continue to be an important and widely used technique in the field of artificial intelligence and machine learning.

--

--