Comprehensive Guide to Decision Tree Learning and Information-Theoretic Foundations

Course Context and Assessment Administration

  • Course Enrollment and Attendance:

    • Total enrolled students: approximately 4040 students.

    • Classroom attendance: substantially fewer than 4040 students attend the physical sessions.

    • Attendance tracking rationale: the roster is reviewed exclusively to organize student project groups for the first assessment, ensuring no assigned groups consist entirely of absent students.

    • Course policy on attendance: presence in class does not carry direct grading consequences; its sole functional use is group distribution.

  • Critical Exam Benchmarks and Core Prerequisites:

    • Differentiating between the evaluation of an intermediate hypothesis and the testing of the final hypothesis is a foundational concept.

    • Failing to clearly articulate the difference between hypothesis evaluation during training/validation and testing the final hypothesis on unseen test data serves as direct grounds for failure in the oral examination.

Core Principles of Supervised and Unsupervised Learning

  • Learning from Data:

    • Data is the fundamental prerequisite of machine learning: without data, no learning can occur.

    • The objective of any learning algorithm is to induce a hypothesis or prediction function that extracts useful, generalizable structure rather than rote memorization.

  • Formalization of Usefulness via Loss Functions:

    • Usefulness is formalized mathematically through a loss function.

    • A loss function quantifies prediction errors and measures the quality of a prediction function against empirical targets.

    • A machine learning algorithm functions primarily by minimizing the defined loss function over the training data.

  • Paradigms of Machine Learning:

    • Supervised Learning: the learning algorithm receives labeled training data and searches for a hypothesis that correctly maps input instances to known target labels.

    • Unsupervised Learning: instances lack target labels; the algorithm discovers underlying patterns or groupings within the data (most commonly via clustering methods).

  • The Role of Testing and Generalization:

    • Evaluating a model solely on training data is insufficient, as an algorithm can achieve arbitrary or perfect accuracy on training data while failing entirely on unseen instances.

    • Testing the learned prediction function on an independent test dataset is essential to detect overfitting and verify genuine predictive performance.

Decision Tree Foundations and Representation

  • Characteristics of Decision Tree Models:

    • Decision tree learning is one of the classic, long-established machine learning algorithms.

    • Key computational attributes: conceptually straightforward, computationally efficient to evaluate, and highly effective when working with small datasets.

    • Comparison with Deep Learning / Neural Networks:

    • Neural networks require large sample sizes to train parameters effectively without severe overfitting.

    • Decision trees remain preferable when available data is limited.

    • Decision trees provide intrinsic interpretability; human practitioners can inspect decision nodes directly, making them central to explainable artificial intelligence (XAI\text{XAI}), whereas neural networks remain opaque black-box models.

  • Formal Mathematical Framework of Supervised Learning:

    • Instance space: XX, representing the set of all possible input instances.

    • Label space: YY, representing the set of possible target categories or values.

    • True target function: an unknown labeling function f:X→Yf: X \rightarrow Y.

    • Hypothesis space: HH, representing the set of candidate functions the algorithm can output.

    • Training set: a finite collection of labeled pairs D={(x1,y1),(x2,y2),…,(xn,yn)}D = \{ (\mathbf{x}_1, y_1), (\mathbf{x}_2, y_2), \dots, (\mathbf{x}_n, y_n) \}, where xi∈X\mathbf{x}_i \in X and yi=f(xi)∈Yy_i = f(\mathbf{x}_i) \in Y.

    • Algorithmic objective: select a hypothesis h∈Hh \in H that approximates the unknown target function ff as closely as possible.

  • Decision Tree Architectural Components:

    • Decision Nodes (Internal Nodes): specify a test condition evaluated on a single attribute.

    • Branches: emanate from decision nodes, corresponding to specific attribute values or threshold outcomes.

    • Leaf Nodes (Terminal Nodes): assign the final classification label or predicted value.

  • Weather Benchmark Dataset Example:

    • A classical discrete classification dataset (from Tom Mitchell's Machine Learning textbook, referenced via Moodle):

    • Label: Binary target indicating whether an activity occurs (Yes\text{Yes} or No\text{No}).

    • Attribute 1 (Outlook\text{Outlook}): discrete values in {sunny,overcast,rain}\{\text{sunny}, \text{overcast}, \text{rain}\}.

    • Attribute 2 (Temperature\text{Temperature}): discrete values in {hot,mild,cold}\{\text{hot}, \text{mild}, \text{cold}\}.

    • Attribute 3 (Humidity\text{Humidity}): discrete values in {high,normal}\{\text{high}, \text{normal}\}.

    • Attribute 4 (Wind\text{Wind}): discrete values in {weak,strong}\{\text{weak}, \text{strong}\}.

    • Classification path examples:

    • If Outlook=sunny\text{Outlook} = \text{sunny} and Humidity=high\text{Humidity} = \text{high}, predict No\text{No}.

    • If Outlook=sunny\text{Outlook} = \text{sunny} and Humidity=normal\text{Humidity} = \text{normal}, predict Yes\text{Yes}.

    • If Outlook=overcast\text{Outlook} = \text{overcast}, predict Yes\text{Yes}.

    • If Outlook=rain\text{Outlook} = \text{rain} and Wind=weak\text{Wind} = \text{weak}, predict Yes\text{Yes}.

    • If Outlook=rain\text{Outlook} = \text{rain} and Wind=strong\text{Wind} = \text{strong}, predict No\text{No}.

  • Logical Formula Equivalence:

    • Every decision tree maps directly to an equivalent propositional logic formula in Disjunctive Normal Form (DNF\text{DNF}).

    • Decoding the positive classification (Yes\text{Yes}) from the weather tree yields:     Predict Yes  ⟺  (Outlook=sunny∧Humidity=normal)∨(Outlook=overcast)∨(Outlook=rain∧Wind=weak)\text{Predict Yes} \iff (\text{Outlook} = \text{sunny} \land \text{Humidity} = \text{normal}) \lor (\text{Outlook} = \text{overcast}) \lor (\text{Outlook} = \text{rain} \land \text{Wind} = \text{weak})

    • Rule-based formulation:

    • Multi-class classification problems are readily handled by translating branches into sets of production rules (IF condition THEN class\text{IF } \text{condition} \text{ THEN } \text{class}).

    • IF (Outlook=sunny∧Humidity=normal)  ⟹  Yes\text{IF } (\text{Outlook} = \text{sunny} \land \text{Humidity} = \text{normal}) \implies \text{Yes}

    • IF (Outlook=sunny∧Humidity=high)  ⟹  No\text{IF } (\text{Outlook} = \text{sunny} \land \text{Humidity} = \text{high}) \implies \text{No}

    • IF (Outlook=overcast)  ⟹  Yes\text{IF } (\text{Outlook} = \text{overcast}) \implies \text{Yes}

  • Decision Boundaries and Continuous Attributes:

    • Continuous attributes are incorporated by selecting a split threshold θ\theta.

    • Example: a split on Humidity>75%\text{Humidity} > 75\% branches to No\text{No}, while Humidity≤75%\text{Humidity} \le 75\% branches to Yes\text{Yes}.

    • Geometry of standard univariate decision trees:

    • Tests evaluate only one variable at a time.

    • Resulting decision boundaries are strictly orthogonal to coordinate axes (axis-parallel hyperplanes).

    • Trees cannot produce sloped or diagonal decision boundaries across multiple coordinates using single-variable splits.

    • Oblique / Linear Decision Trees:

    • Can test linear combinations of attributes: wTx+b>0\mathbf{w}^T \mathbf{x} + b > 0.

    • Enables sloped, non-axis-parallel boundaries.

    • Disadvantage: calculating the optimal weight vector w\mathbf{w} at each internal node introduces severe computational complexity, rendering standard axis-parallel univariate tests the prevailing convention.

Tree Complexity, Model Selection, and Occam's Razor

  • The Selection Dilemma Among Accurate Trees:

    • When multiple candidate trees achieve identical accuracy on training data, selecting the simpler model is preferred.

  • Rationale for Simplicity:

    • Operational and Interpretability Benefits: simpler trees contain fewer decision nodes, making them easier to read, audit, deploy, and adjust.

    • Occam's Razor Principle: entities should not be multiplied beyond necessity; the simplest hypothesis that explains the data is most likely to capture the true underlying distribution.

    • Overfitting Prevention: overly complex trees tend to model stochastic noise within the training data rather than the actual underlying phenomenon.

    • Attribute Cost Considerations: in practical domains such as medical diagnosis, evaluating individual attributes involves monetary, physical, or time costs (e.g., diagnostic lab tests). Minimizing decision depth directly minimizes evaluation expenses.

  • Defining and Quantifying Tree Complexity:

    • Complexity lacks a single, universal metric.

    • Standard metrics count the total number of decision nodes, total leaf nodes, or maximum tree depth.

Data Splitting Heuristics and Mathematical Measures of Impurity

  • Ineffective vs. Effective Splitting:

    • Splitting data evenly by sample count (e.g., partitioning 5050 positive and 5050 negative samples into two branches of 2525 positives and 2525 negatives each) provides zero classification utility.

    • The objective of a split is to maximize label purity within child partitions, thereby reducing label uncertainty.

  • Misclassification Error Criterion and Its Pitfalls:

    • Misclassification error can be used to score candidate splits by counting errors under majority-rule voting in terminal partitions.

    • Example scenario on a dataset of 100100 instances (4949 positive, 5151 negative):

    • Baseline prediction without split: assign all samples to the majority class (negative), resulting in 4949 errors out of 100100.

    • Candidate Split 1 (Attribute 1): yields child subsets containing (40 (+),9 (−))(40\,(+), 9\,(-)) and (9 (+),42 (−))(9\,(+), 42\,(-)).

      • Node 1 majority prediction is positive: 99 errors.

      • Node 2 majority prediction is negative: 99 errors.

      • Total errors: 9+9=189 + 9 = 18 (or 4141 depending on alternative subset assignments like (40,9)(40, 9) and (10,41)(10, 41)).

    • Candidate Split 2 (Attribute 2): evaluated by totaling minority instances across resulting partitions (e.g., yielding 3636 or 3838 total errors).

    • Limitation: despite intuitive appeal, empirical evidence demonstrates that minimizing raw misclassification error often yields suboptimal trees because it is insensitive to shifts in class probabilities toward extreme purity.

Information Theory, Entropy, and Optimal Coding Length

  • Information and Uncertainty:

    • Information gain directly quantifies the reduction of uncertainty achieved by partitioning data according to an attribute.

    • Information content is inversely proportional to probability: an event that is completely certain contains zero information.

  • Information-Theoretic Entropy:

    • Entropy (HH) measures the average uncertainty or disorder of a probability distribution.

    • For a binary random variable with positive class probability pp and negative class probability 1−p1 - p:     H(p)=−plog⁡2(p)−(1−p)log⁡2(1−p)H(p) = -p \log_2(p) - (1 - p) \log_2(1 - p)

    • Boundary conditions:

    • If p=0p = 0 or p=1p = 1, the outcome is completely certain, and H(p)=0H(p) = 0.

    • If p=0.5p = 0.5, uncertainty is maximized, and H(p)=1 bitH(p) = 1\,\text{bit}.

  • Derivation from Optimal Coding Length (Shannon's Source Coding Theorem):

    • Consider a message alphabet of four symbols: A,B,C,DA, B, C, D.

    • Probability distribution: P(A)=0.5P(A) = 0.5, P(B)=0.25P(B) = 0.25, P(C)=0.125P(C) = 0.125, P(D)=0.125P(D) = 0.125.

    • Uniform Fixed-Length Encoding:

    • Four distinct symbols require log⁡2(4)=2 bits\log_2(4) = 2\,\text{bits} per symbol (e.g., A=00A = 00, B=01B = 01, C=10C = 10, D=11D = 11).

    • Transmitting a sequence of 10001000 symbols requires exactly 2000 bits2000\,\text{bits}.

    • Optimal Variable-Length (Prefix-Free) Encoding:

    • Assign shorter bit sequences to more frequent symbols so that no code word is a prefix of another:

      • Code for AA: 11 (length 1 bit1\,\text{bit})

      • Code for BB: 0101 (length 2 bits2\,\text{bits})

      • Code for CC: 000000 (length 3 bits3\,\text{bits})

      • Code for DD: 001001 (length 3 bits3\,\text{bits})

    • Expected code length per symbol:       L=(0.5×1)+(0.25×2)+(0.125×3)+(0.125×3)L = \left(0.5 \times 1\right) + \left(0.25 \times 2\right) + \left(0.125 \times 3\right) + \left(0.125 \times 3\right)       L=0.5+0.5+0.375+0.375=1.75 bits=74 bitsL = 0.5 + 0.5 + 0.375 + 0.375 = 1.75\,\text{bits} = \frac{7}{4}\,\text{bits}

    • Comparison: transmitting 10001000 symbols requires 1750 bits1750\,\text{bits} instead of 2000 bits2000\,\text{bits}.

    • Identity with Entropy:

    • Applying the entropy formula directly to this distribution:       H(X)=−∑iP(xi)log⁡2(P(xi))H(X) = -\sum_{i} P(x_i) \log_2(P(x_i))       H(X)=−(0.5log⁡2(0.5)+0.25log⁡2(0.25)+0.125log⁡2(0.125)+0.125log⁡2(0.125))H(X) = -\left(0.5 \log_2(0.5) + 0.25 \log_2(0.25) + 0.125 \log_2(0.125) + 0.125 \log_2(0.125)\right)       H(X)=−(0.5(−1)+0.25(−2)+0.125(−3)+0.125(−3))H(X) = -\left(0.5(-1) + 0.25(-2) + 0.125(-3) + 0.125(-3)\right)       H(X)=0.5+0.5+0.375+0.375=1.75 bitsH(X) = 0.5 + 0.5 + 0.375 + 0.375 = 1.75\,\text{bits}

    • The entropy exactly equals the theoretical minimum average code length required to encode the labels.

  • Total Entropy of a Dataset:

    • For a sample of size nn with class proportion pp, total uncertainty is represented by n×H(p)n \times H(p).

    • When partitioned into subsets S1S_1 and S2S_2 of sizes n1n_1 and n2n_2 (where n=n1+n2n = n_1 + n_2), the remaining entropy after the split is:     H(S1,S2)=n1nH(p1)+n2nH(p2)H(S_1, S_2) = \frac{n_1}{n} H(p_1) + \frac{n_2}{n} H(p_2)

    • Weighting by subset size ensures that achieving high purity on large subsets provides a substantially greater gain than achieving purity on trivial, tiny subsets.

Top-Down Induction of Decision Trees (TDIDT) and Algorithmic Limitations

  • Computational Complexity of Optimal Trees:

    • Finding the smallest (minimal size) decision tree that perfectly classifies a given training dataset is an NP\text{NP}-complete / NP\text{NP}-hard optimization problem.

    • Exact global optimization is computationally intractable for realistic data dimensions.

  • Greedy Top-Down Recursive Partitioning:

    • Practical algorithms utilize Top-Down Induction of Decision Trees (TDIDT\text{TDIDT}).

    • Characteristics:

    • Starts at the root node and recursively chooses the locally optimal split.

    • Employs a one-step lookahead greedy heuristic, selecting the attribute that maximizes immediate information gain.

    • Never backtracks to re-evaluate higher-level split choices once partitioned.

  • Failure Modes of Greedy One-Step Lookahead (XOR / Parity Problem):

    • A greedy strategy can fail when classification requires multi-attribute interaction (e.g., exclusive-OR relationships).

    • Example setup:

    • Consider three binary attributes (A1,A2,A3A_1, A_2, A_3) and four balanced instance groups of 2525 samples each (100100 samples total).

    • Target label depends strictly on the joint XOR combination of A1A_1 and A2A_2:

      • (A1=0,A2=0)  ⟹  (+)(A_1 = 0, A_2 = 0) \implies (+)

      • (A1=1,A2=1)  ⟹  (+)(A_1 = 1, A_2 = 1) \implies (+)

      • (A1=0,A2=1)  ⟹  (−)(A_1 = 0, A_2 = 1) \implies (-)

      • (A1=1,A2=0)  ⟹  (−)(A_1 = 1, A_2 = 0) \implies (-)

    • Evaluating single-attribute splits on A1A_1 or A2A_2 individually yields exactly 50 %50\,\% positive and 50 %50\,\% negative instances in each branch, producing zero information gain.

    • Attribute A3A_3 (an irrelevant feature) might superficially separate a subset (e.g., isolating 2525 negative cases purely by chance), causing the greedy algorithm to pick A3A_3.

    • Consequence: splitting on A3A_3 fragments the remaining instances such that the algorithm cannot perfectly separate the classes in subsequent steps without compounding errors.

    • In contrast, evaluating a two-step lookahead would reveal that splitting on A1A_1 followed immediately by A2A_2 yields perfect classification accuracy.

    • Multi-Step Lookahead Trade-off: evaluating combinations of two or more splits simultaneously resolves interaction blind spots but substantially increases computational cost.

Advanced Splitting Criteria, Continuous Attributes, and Missing Data

  • Comparison of Impurity Metrics:

    • Information Gain (Entropy):     H(p)=−plog⁡2(p)−(1−p)log⁡2(1−p)H(p) = -p \log_2(p) - (1 - p) \log_2(1 - p)

    • Gini Impurity (used in CART):     Gini(p)=2p(1−p)Gini(p) = 2p(1 - p)

    • Serves as a smooth, computationally efficient polynomial approximation of entropy without requiring logarithmic evaluations.

    • Misclassification Error:     Error(p)=1−max⁡(p,1−p)Error(p) = 1 - \max(p, 1 - p)

    • Geometric relationship: all three functions peak at p=0.5p = 0.5 and equal 00 at p=0p = 0 and p=1p = 1, but Entropy and Gini have continuous gradients that reward incremental purifications near the extremes.

  • Bias of Information Gain Toward Multi-Valued Attributes:

    • Attributes with large numbers of distinct values (e.g., unique customer IDs or fine-grained categories) possess an unfair advantage over binary attributes.

    • A multi-valued attribute can shatter the dataset into numerous small, trivial subsets that appear perfectly pure, achieving high Information Gain while generalizing poorly.

  • Gain Ratio Correction (C4.5 Algorithm):

    • The C4.5C4.5 algorithm addresses this multi-valued bias by normalizing Information Gain using Split Information:     GainRatio(S,A)=Gain(S,A)SplitInformation(S,A)\text{GainRatio}(S, A) = \frac{\text{Gain}(S, A)}{\text{SplitInformation}(S, A)}

    • Split Information measures the potential information generated by splitting dataset SS into kk partitions based on attribute AA:     SplitInformation(S,A)=−∑i=1k∣Si∣∣S∣log⁡2(∣Si∣∣S∣)\text{SplitInformation}(S, A) = -\sum_{i=1}^k \frac{|S_i|}{|S|} \log_2\left(\frac{|S_i|}{|S|}\right)

    • Splitting on attributes with broad, fragmented distributions incurs a large Split Information denominator, heavily penalizing the Gain Ratio.

    • Implementation nuances:

    • Binary splitting can be enforced instead of multi-way splits to constrain unnecessary node proliferation.

    • When calculating Split Information, attributes with many theoretical values that only exhibit a few values in the actual training sample should be evaluated based only on observed values.

  • Threshold Selection for Continuous Attributes:

    • Continuous attributes are evaluated by sorting observed distinct numerical values in the training set.

    • Candidate thresholds are positioned between adjacent sorted values.

    • The algorithm selects the threshold yielding the highest Information Gain.

    • Multiple-hypothesis penalties: testing many continuous threshold candidates increases degrees of freedom, which can be compensated for by incorporating model-complexity penalties.

  • Handling Missing Attribute Values:

    • Strategy in C4.5C4.5: implements an explicit dedicated branch for missing values, routing examples lacking an attribute measurement directly through this path.

    • Advantage: avoids artificial imputation or numerical substitution (e.g., mean/mode replacement), which can introduce bias into the learned tree structure.

Overfitting, Stopping Criteria, and Hyperparameter Optimization

  • Overfitting Dynamics in Decision Trees:

    • A tree grown until every leaf is completely pure achieves 100%100\% accuracy on the training data.

    • In real-world data containing noise or stochastic label errors, unconstrained growth models the noise, degrading generalization performance on unseen test data.

  • Early Stopping (Pre-Pruning) Criteria:

    • Rather than growing a maximal tree and pruning backwards, growth can be terminated early based on predefined hyperparameter thresholds:

    • Maximum tree depth: halt recursion once a fixed depth limit is reached.

    • Maximum number of nodes: constrain the total count of decision and leaf nodes.

    • Node sample threshold: do not split nodes containing fewer than a specified minimum number of instances.

    • Impurity threshold: halt splitting when node impurity falls below a target threshold.

  • The Model Selection Problem and Validation Sets:

    • Determining optimal tree complexity cannot be achieved using training data alone, as training error monotonically decreases as complexity increases.

    • Hyperparameters (such as maximum node count or maximum tree depth) must be tuned using independent validation data.

    • Search procedure:

    • Fix candidate hyperparameter values (e.g., varying max node limits across a grid).

    • Train distinct trees on the training split up to each candidate threshold.

    • Measure empirical classification accuracy on the validation split.

    • Select the hyperparameter value that minimizes generalization error on validation data.

In-Class Dialogue and Technical Q&A

  • Assessment and Roster Check Exchange:

    • Question / Clarification: What is the formal purpose of checking student attendance off the roster?

    • Clarification Response: The roster check is conducted because approximately 4040 students are enrolled, yet far fewer are present in class. Its sole objective is to assign functional groups for the first assessment without creating empty groups containing zero active students. It carries no attendance grade penalties.

  • Review of Prior Lecture Concepts:

    • Question: What are the three most critical concepts from the preceding foundational lecture?

    • Student Responses:

    • Differentiating between measuring prediction usefulness and evaluating incorrect predictions.

    • Minimizing loss functions rather than relying strictly on raw classification accuracy.

    • Factoring in misclassification costs.

    • Distinguishing between intermediate hypothesis evaluation and testing the final hypothesis.

    • Concepts of overfitting and underfitting.

    • Clarification Response: The loss function is the formal mathematical representation of usefulness, and machine learning algorithms operate fundamentally by minimizing this loss function over training data. Furthermore, confusing hypothesis evaluation with final hypothesis testing is a direct reason to fail the oral exam.

  • Splitting Criteria Dialogue:

    • Question: What defines a good split at a decision node? Does an even 50/5050/50 split by sample counts constitute a useful split?

    • Student Response: A split that divides the data evenly by equal numbers of samples.

    • Clarification Response: An even split that preserves balanced class proportions (e.g., dividing 50 (+)50\,(+) and 50 (−)50\,(-) into two subsets of 25 (+)25\,(+) and 25 (−)25\,(-)) provides zero label information. A useful split must separate the positive and negative class distributions to reduce label uncertainty.

  • Measuring Uncertainty Dialogue:

    • Question: What is the classical scientific metric used to measure uncertainty or disorder?

    • Student Responses: Suggestions included distance metrics, physical ranges, or values of 00 versus 11.

    • Clarification Response: The classical measure used across physics and information theory is entropy.

  • Hyperparameter Tuning Strategy:

    • Question: In model selection, does one train an overfitted model and an underfitted model and pick an intermediate compromise?

    • Clarification Response: The standard procedure is a search over hyperparameter space. If tuning maximum node count, the algorithm trains trees with different node limits, evaluates each on separate validation data, and selects the parameter value that produces the lowest error on that extra data.