∑GATE DA Atlas

Decision Trees

How decision trees partition the feature space, greedy top-down induction, impurity measures (entropy, Gini, misclassification error), information gain and gain ratio worked step by step, splitting numeric attributes, regression trees with variance reduction, stopping rules and pruning, overfitting, and ensembles built from trees (bagging, random forests, boosting).

Section 610 practice questions

How a decision tree predicts

A decision tree asks a sequence of simple questions about one feature at a time ("Outlook = sunny?", "age < 30?"). Internal nodes test a feature, branches are outcomes, and leaves hold a prediction (a class, or a number for regression). The tree partitions the feature space into axis-aligned rectangles.

Outlook? Humidity? Yes Wind? No Yes No Yes sunnyovercastrain highnormalstrongweak
The classic "play tennis" tree: each root-to-leaf path is an IF–THEN rule.

Growing a tree: greedy top-down induction

  1. Start with all training data at the root.
  2. For every feature (and threshold), measure how much a split would reduce impurity.
  3. Split on the best one; recurse on each child.
  4. Stop when a node is pure, too small, too deep, or no split helps.

This greedy recursive partitioning (ID3, C4.5, CART) is fast but not globally optimal (finding the optimal tree is NP-hard).

Impurity measures

For a node with class proportions p1,…,pKp_1, \dots, p_K:

MeasureFormulaTwo classes, maximum
EntropyH=−∑kpklog⁡2pkH = -\sum_kp_k\log_2p_k1 at p=0.5p = 0.5
Gini impurityG=1−∑kpk2G = 1 - \sum_kp_k^20.5 at p=0.5p = 0.5
Misclassification error1−max⁡kpk1 - \max_kp_k0.5 at p=0.5p = 0.5

Entropy and Gini are smooth and usually pick similar splits; misclassification error is too insensitive for growing trees.

Information gain

Gain(S,A)=H(S)−∑v∈values(A)∣Sv∣∣S∣H(Sv).\text{Gain}(S, A) = H(S) - \sum_{v\in\text{values}(A)}\frac{\lvert S_v\rvert}{\lvert S\rvert}H(S_v).

Gain ratio (C4.5) divides by the split information to avoid favouring many-valued attributes; Gini gain (CART) uses GG in place of HH and makes binary splits.

Numeric features

Sort the values; candidate thresholds are midpoints between consecutive distinct values (only class-changing boundaries matter for entropy). Evaluate each threshold like a binary attribute.

Regression trees

Leaves predict the mean target of their examples; splits minimise the total squared error (variance reduction):

choose (j,t) minimising ∑i∈L(yi−yˉL)2+∑i∈R(yi−yˉR)2.\text{choose } (j, t) \text{ minimising } \sum_{i\in L}(y_i - \bar y_L)^2 + \sum_{i\in R}(y_i - \bar y_R)^2.

Overfitting and pruning

A tree grown until every leaf is pure has zero training error and high variance. Controls:

  • Pre-pruning (early stopping): max depth, minimum samples per leaf/split, minimum impurity decrease.
  • Post-pruning: grow fully, then remove subtrees that do not improve validation performance — reduced-error pruning, or cost-complexity pruning (minimise error+α⋅∣leaves∣\text{error} + \alpha\cdot\lvert\text{leaves}\rvert, with α\alpha chosen by cross-validation).

Strengths and weaknesses

StrengthsWeaknesses
interpretable rules; easy to visualiseunstable: small data changes can change the tree a lot (high variance)
no feature scaling needed; handles mixed typesaxis-aligned splits approximate diagonal boundaries poorly
captures interactions and non-linearitygreedy; can overfit without pruning
fast prediction (O(depth)O(\text{depth}))piecewise-constant regression

Ensembles of trees

MethodIdeaMainly reduces
Baggingtrain trees on bootstrap samples; average/votevariance
Random forestbagging + a random subset of features at each split (decorrelates trees); out-of-bag error estimate for freevariance
Boosting (AdaBoost, gradient boosting, XGBoost)add shallow trees sequentially, each fitting the current errors/residualsbias (and variance)

Quick revision

Practice questions

GATE-style questions: 4 one-mark and 6 two-mark. Wrong MCQs cost ⅓ of their marks in the real exam; MSQ and NAT have no negative marking. Attempt each before opening the solution.

Q1NAT1 mark

A node contains 9 positive and 5 negative examples. Its entropy (base 2) is ______ (round to two decimals).

Q2NAT2 marks

A node has 6 examples of class A and 2 of class B. Its Gini impurity 1−∑kpk21 - \sum_k p_k^2 is ______.

Q3NAT2 marks

A node with 9 positive and 5 negative examples (entropy 0.940) is split on Outlook into Sunny (2+, 3−), Overcast (4+, 0−) and Rain (3+, 2−). The information gain of this split is ______ (round to two decimals).

Q4MCQ1 mark

For a binary classification node, entropy is maximised when the fraction of positive examples is

Q5MSQ2 marks

Which statements about decision trees are correct?

One or more options are correct.

Q6MCQ2 marks

Information gain is biased towards attributes with many distinct values (such as a customer ID). C4.5 corrects this by using

Q7NAT2 marks

A numeric feature takes 6 distinct values in a node's training examples. The number of candidate binary split thresholds (midpoints between consecutive sorted distinct values) is ______.

Q8MCQ1 mark

In a regression tree, a leaf predicts

Q9NAT1 mark

The maximum number of leaves in a binary decision tree of depth 3 (the root is at depth 0) is ______.

Q10MCQ2 marks

A random forest improves on a single deep decision tree mainly by