Decision Trees

A model that predicts by asking a series of yes-or-no questions.

🟢 beginner5 min readsupervisedtrees
A decision tree predicts by asking a series of yes-or-no questions, like is income above 50,000, then is age below 30. At each step it picks the question that best separates the classes, judged by how mixed each group is after the split. Trees handle curved patterns and mixed data types, need no feature scaling, and are easy to explain. Their weakness is overfitting: left to grow, a tree memorises the training data, so you limit its depth or prune it back.

What is a Decision Tree?

A Decision Tree is an intuitive hierarchical model that makes predictions by asking a series of yes/no questions about feature values.

                         [ Credit Score > 700? ]
                         /                     \
                      YES                       NO
                     /                            \
           [ Income > $50k? ]               [ Approved: FALSE ]
           /                \
        YES                  NO
       /                       \
 [ Approved: TRUE ]     [ Approved: FALSE ]

Decision trees partition feature space into axis aligned hyper-rectangles:

  Feature X2
     ▲
     │  Region A (Class 0) │  Region B (Class 1)
  c2 ┼─────────────────────┼─────────────────────
     │  Region C (Class 1) │  Region D (Class 0)
     └─────────────────────┴─────────────────────► Feature X1
                          c1

How Decision Trees Are Built (CART Algorithm)

Classification and Regression Trees (CART) build trees top-down using a Greedy Recursive Binary Splitting approach:

  1. Evaluate Candidate Splits: For every feature jj and every possible threshold value tt, evaluate splitting data into left node DLD_L and right node DRD_R.
  2. Select Best Split: Choose the feature j∗j^* and threshold t∗t^* that minimizes impurity or maximizes Information Gain.
  3. Recurse: Repeat splitting on child nodes until a stopping criterion is met (e.g. maximum depth reached or minimum samples per leaf).

Key Advantages

  1. High Interpretability: Decision trees can be visualized and explained easily to non technical stakeholders.
  2. Zero Feature Scaling Needed: Invariant to monotonic scaling. StandardScaler has zero impact on split choices.
  3. Handles Mixed Data Types: Manages numerical and categorical features naturally.

Key Disadvantages

  1. High Variance & Overfitting: Deep unconstrained trees grow complex leaves that memorize training noise.
  2. Axis Aligned Limits: Struggles to capture smooth diagonal decision boundaries because splits are always orthogonal (perpendicular to axes).
  3. Instability: Small changes in training data can produce a completely different tree hierarchy.

Say this out loud

Decision Trees split data recursively into axis aligned decision regions using greedy threshold splits that maximize impurity reduction. They are highly interpretable and require zero feature scaling. However, unconstrained deep trees suffer from high variance and severe overfitting, which is fixed by pruning or ensembling into Random Forests.

Followups to expect

  1. How does a Decision Tree make predictions for Regression tasks? The tree predicts the mean target value of all training samples falling into that specific leaf node, using Mean Squared Error to select splits.
  2. What is Cost Complexity Pruning (α pruning)? Pruning subtrees that add excessive leaf nodes unless they reduce total impurity by more than penalty factor α\alpha.

Check yourself

Question 1 of 3

Why do unconstrained deep Decision Trees suffer from severe overfitting on training data?

More in Classical ML

See all →
Bias–Variance Tradeoff4 minOverfitting vs Underfitting3 minLinear Regression4 min