Skip to main content

Unit 4 Cheat Sheet: Decision Trees & Ensemble Learning

Course - Machine Learning Algorithms (21CSC555J)
Assessment - Continuous Test 2 (CT-2)
Scope - CART Classification Trees (Gini Index, Binary Splitting) and AdaBoost (Stumps, Weight Updates, Bias-Variance)
Primary Reference - Unit 4 Full Exam Solutions


1. Exam Overview & Fast Mapping (40 Marks)​

QuestionAlgorithm & TopicCore Numerical ShortcutEssential Theory Keywords
Q3 (20M)CART Tree: Customer Buy DecisionRoot Gini =2449≈0.4898  ⟹  = \frac{24}{49} \approx 0.4898 \implies Age Group split {Young}\{\text{Young}\} vs {Mid, Sen}\{\text{Mid, Sen}\} wins (Gini=0.2286\text{Gini} = 0.2286, Δ=0.2612\Delta = 0.2612)Binary splitting (2k−1−12^{k-1}-1), Cost-complexity pruning, Tie-breaking rules
Q4 (20M)AdaBoost: Transaction Fraud Classification10%10\% error   ⟹  Odds=9  ⟹  α=12ln⁡(9)=ln⁡(3)≈1.0986\implies \text{Odds} = 9 \implies \alpha = \frac{1}{2}\ln(9) = \ln(3) \approx \mathbf{1.0986}Decision stumps (high bias/low variance), Sequential reweighting, Missing value bypassing

2. Question 3: CART Classification Tree (20 Marks)​

Step 1: Root Node Gini Calculation (4 Marks)​

  • Total N=7  ⟹  NYes=4N = 7 \implies N_{\text{Yes}} = 4 (C3, C4, C5, C6),   NNo=3\; N_{\text{No}} = 3 (C1, C2, C7)
  • Formula: Gini(Root)=1−[(47)2+(37)2]=1−2549=2449≈0.4898\text{Gini}(\text{Root}) = 1 - \left[ \left(\frac{4}{7}\right)^2 + \left(\frac{3}{7}\right)^2 \right] = 1 - \frac{25}{49} = \mathbf{\frac{24}{49} \approx 0.4898}

Step 2: Binary Splits Speed Table (8 Marks)​

CART requires testing all 2k−1−1=32^{k-1}-1 = 3 candidate binary partitions per attribute: Ginisplit=NLNGini(DL)+NRNGini(DR)\text{Gini}_{\text{split}} = \frac{N_L}{N}\text{Gini}(D_L) + \frac{N_R}{N}\text{Gini}(D_R)

AttributeCandidate Binary PartitionLeft Node (DLD_L)Right Node (DRD_R)Weighted GiniRank / Status
Age Group{Young}\{\text{Young}\} vs {Middle, Senior}\{\text{Middle, Senior}\}0 Yes, 2 No (0.0\mathbf{0.0}, Pure)4 Yes, 1 No (0.3200.320)27(0)+57(0.320)≈0.2286\frac{2}{7}(0) + \frac{5}{7}(0.320) \approx \mathbf{0.2286}WINNER (Best Split)
Age Group{Middle}\{\text{Middle}\} vs {Young, Senior}\{\text{Young, Senior}\}2 Yes, 0 No (0.0\mathbf{0.0}, Pure)2 Yes, 3 No (0.4800.480)27(0)+57(0.480)≈0.3429\frac{2}{7}(0) + \frac{5}{7}(0.480) \approx 0.3429Suboptimal
Age Group{Senior}\{\text{Senior}\} vs {Young, Middle}\{\text{Young, Middle}\}2 Yes, 1 No (0.4440.444)2 Yes, 2 No (0.5000.500)37(0.444)+47(0.5)≈0.4762\frac{3}{7}(0.444) + \frac{4}{7}(0.5) \approx 0.4762Suboptimal
Income Level{High}\{\text{High}\} vs {Low, Medium}\{\text{Low, Medium}\}2 Yes, 0 No (0.0\mathbf{0.0}, Pure)2 Yes, 3 No (0.4800.480)27(0)+57(0.480)≈0.3429\frac{2}{7}(0) + \frac{5}{7}(0.480) \approx \mathbf{0.3429}Best for Income
Income Level{Low}\{\text{Low}\} vs {Medium, High}\{\text{Medium, High}\}1 Yes, 2 No (0.4440.444)3 Yes, 1 No (0.3750.375)37(0.444)+47(0.375)≈0.4048\frac{3}{7}(0.444) + \frac{4}{7}(0.375) \approx 0.4048Suboptimal
Income Level{Medium}\{\text{Medium}\} vs {Low, High}\{\text{Low, High}\}1 Yes, 1 No (0.5000.500)3 Yes, 2 No (0.4800.480)27(0.5)+57(0.480)≈0.4857\frac{2}{7}(0.5) + \frac{5}{7}(0.480) \approx 0.4857Suboptimal

Step 3: Best Attribute Decision (4 Marks)​

  • Age Group Gain: ΔGini=0.4898−0.2286=0.2612\Delta \text{Gini} = 0.4898 - 0.2286 = \mathbf{0.2612} (Maximum Gain)
  • Income Level Gain: ΔGini=0.4898−0.3429=0.1469\Delta \text{Gini} = 0.4898 - 0.3429 = 0.1469
  • Decision: Choose Age Group with split condition {Young}\{\text{Young}\} vs {Middle, Senior}\{\text{Middle, Senior}\}. It yields lowest impurity and cleanly isolates an immediately pure leaf node (Young  ⟹  No\text{Young} \implies \text{No}).

Step 4: Theory Scoring Points (4 Marks)​

  • Tie-Breaking Protocols (2 Marks):
    1. Acquisition cost: choose feature cheaper to collect in practice.
    2. Subtree balance: choose split creating more evenly sized child nodes.
    3. Schema order: default to first column in dataset table.
    4. Secondary metric: compute Information Gain (Entropy).
  • Two Advantages of CART over ID3/C4.5 (2 Marks):
    1. Classification & Regression Support: Handles categorical (Gini) and continuous targets (MSE / variance reduction).
    2. Strict Binary Splitting: Avoids multi-way branch fragmentation, preserving sample size in deeper nodes.
    3. Disciplined Cost-Complexity Pruning: Minimal cost-complexity α\alpha-pruning validated with cross-validation.

3. Question 4: AdaBoost Fraud Classifier (20 Marks)​

Core Weight Update Formulas​

  1. Initial weights: wi(1)=1Nw_i^{(1)} = \frac{1}{N}
  2. Weighted error: ϵm=∑misclassifiedwi(m)\epsilon_m = \sum_{\text{misclassified}} w_i^{(m)}
  3. Stump importance: αm=12ln⁡(1−ϵmϵm)\alpha_m = \frac{1}{2}\ln\left(\frac{1 - \epsilon_m}{\epsilon_m}\right)
  4. Sample update:
    • Correct: wi(m+1)=wi(m)⋅e−αmw_i^{(m+1)} = w_i^{(m)} \cdot e^{-\alpha_m} (attenuated)
    • Wrong: wi(m+1)=wi(m)⋅e+αmw_i^{(m+1)} = w_i^{(m)} \cdot e^{+\alpha_m} (boosted)
    • Normalize by Zm=∑wi(m+1)Z_m = \sum w_i^{(m+1)} so weights sum to 11.

10% Misclassification Numerical Shortcut (Sub-part iii: 4 Marks)​

  • Error rate: ϵm=10%=0.10\epsilon_m = 10\% = 0.10 (Holds when weights are uniform, as in round 1)
  • Odds ratio: 1−ϵmϵm=0.900.10=9\frac{1 - \epsilon_m}{\epsilon_m} = \frac{0.90}{0.10} = 9
  • Importance weight: αm=12ln⁡(9)=12ln⁡(32)=ln⁡(3)≈1.0986\alpha_m = \frac{1}{2}\ln(9) = \frac{1}{2}\ln(3^2) = \ln(3) \approx \mathbf{1.0986} (Note: Textbooks omitting 12\frac{1}{2} yield α=ln⁡(9)≈2.1972\alpha = \ln(9) \approx 2.1972. Use standard Freund & Schapire 12ln⁡\frac{1}{2}\ln form unless specified).
  • Meaning: High positive voting weight in final ensemble rule H(x)=sign(∑αmhm(x))H(\mathbf{x}) = \text{sign}\left(\sum \alpha_m h_m(\mathbf{x})\right).

Theory Scoring Points​

  • Why Decision Stumps? (4 Marks):
    1. Easily satisfies weak learner condition (ϵ<0.5\epsilon < 0.5).
    2. High bias, ultra-low variance: Starting with low-variance models prevents ensemble variance from exploding.
    3. Fast training: Only O(N⋅D)O(N \cdot D) split evaluations.
    4. Interpretability: Aggregated stump weights directly yield feature importance scores.
  • Bias vs Variance in Boosting (4 Marks):
    • Reduces Bias: Each stump focuses on samples earlier stumps got wrong through higher sample weights (not residual fitting); linear combination builds non-linear boundaries.
    • Increases Variance: Repeatedly misclassified noisy points keep gaining relative weight after normalization, forcing later stumps to overfit noise pockets.
  • Handling Missing "Device ID" (4 Marks):
    • AdaBoost has NO built-in missing value handling; it inherits base learner / pipeline behavior:
    1. Option A (Imputation): Impute via mode/median before training.
    2. Option B (Separate Category): Treat Missing as a distinct level (Device_ID = Unknown), capturing deliberate fraud concealment.
    3. Option C (Base Learner Handling): Use stumps that natively handle missing values (CART surrogate splits or C4.5 fractional weights).

4. Golden Numbers & Exam Traps​

Quick Number Reference​

  • Q3 CART Tree: Root Gini =2449≈0.4898= \frac{24}{49} \approx 0.4898, Age Best Gini =0.2286= 0.2286 (Gain =0.2612= 0.2612), Income Best Gini =0.3429= 0.3429 (Gain =0.1469= 0.1469).
  • Q4 AdaBoost: ϵ=0.10  ⟹  Odds=9  ⟹  α=ln⁡(3)≈1.0986\epsilon = 0.10 \implies \text{Odds} = 9 \implies \alpha = \ln(3) \approx 1.0986. Correct factor =e−1.0986=1/3= e^{-1.0986} = 1/3, Wrong factor =e+1.0986=3.0= e^{+1.0986} = 3.0.
danger

Avoid These Common Traps

  1. Gini vs Entropy: Gini uses squared probabilities (1−∑pi21 - \sum p_i^2). Do NOT use logarithms.
  2. Binary vs Multi-Way Splits: CART always tests binary partitions (2k−1−12^{k-1}-1). Don't just compute a single 3-way split.
  3. Weight Update Signs: Misclassified instances get e+αe^{+\alpha} (increased); correctly classified instances get e−αe^{-\alpha} (decreased).
  4. Log Base in α\alpha: Use the natural logarithm (ln⁡\ln), not log⁡10\log_{10} or log⁡2\log_2.