Concepts and worked examples

Decision Trees and Supervised Segmentation

See how decision trees split data, make predictions, and avoid overfitting.

Learning rules from examples

Induction means learning a pattern from examples, then using it on new cases. The features are the details used to make a prediction; the target is the answer to learn. A decision tree asks a series of questions. A new example follows those questions to a final branch, which gives a class, probability, or number.

This is supervised segmentation: groups are chosen to differ with respect to a target. It is not ordinary unsupervised clustering, which groups examples according to similarity without using the same outcome criterion. A predictive model estimates an unknown target; descriptive analysis can characterize segments without claiming successful out-of-sample prediction.

Tree induction commonly considers candidate categorical partitions or numeric thresholds, scores each split, chooses a locally attractive one, and repeats within children. This greedy search does not guarantee the globally optimal tree. A useful numeric predictor does not have to be converted into arbitrary bins first; many implementations search thresholds between sorted observed values.

Entropy measures class uncertainty

For a node containing class proportions p₁ through p_K, entropy is H = −Σₖ pₖ log₂(pₖ), with 0 log₂(0) defined as zero. A pure node has entropy zero. A balanced binary node has entropy one bit, the binary maximum. Entropy describes uncertainty in class labels within a node, not the spread of arbitrary feature values.

Information gain compares parent uncertainty with the weighted average uncertainty after splitting. The class proportions inside each entropy calculation differ from the child-size weights used outside it.

IG = H(parent) − Σⱼ (Nⱼ / N)H(childⱼ)

Here N is the number of examples at the parent being split, not necessarily the entire original training dataset. Weighting prevents a tiny pure child from receiving the same influence as a large impure one. Other criteria, such as Gini impurity, are also common; entropy is not mandatory for every tree algorithm.

Worked example: compare a parent with its children

A parent has ten accounts: six renew and four do not. Its entropy is −0.6 log₂(0.6) − 0.4 log₂(0.4) ≈ 0.971 bits. A candidate split produces a left child with four renewals and no non-renewals, and a right child with two renewals and four non-renewals.

Entropy and sample weights for the candidate split
NodeRenew / notEntropyChild weight
Parent6 / 40.971Not applicable
Left4 / 004/10
Right2 / 40.9186/10

Weighted child entropy is (4/10) × 0 + (6/10) × 0.918 ≈ 0.551. Information gain is 0.971 − 0.551 ≈ 0.420 bits. This improves training purity; it does not prove that the split will improve future profit or remain stable on new accounts.

Leaves predict outcomes, not certainties

A classification leaf can predict its majority class. For class probability estimation, the raw positive frequency is n/(n + m), where n positives and m negatives reach that leaf. Binary Laplace smoothing gives (n + 1)/(n + m + 2), equivalent to adding one observation to each class under a symmetric Beta(1,1) prior.

A leaf with one positive and no negatives gives raw probability 1 but smoothed probability 2/3, not 3/4. A leaf with two positives and no negatives gives 3/4. The worked split's left leaf gives 5/6 ≈ 0.833; its right leaf gives 3/8 = 0.375. For K classes, add-one smoothing is (n_c + 1)/(N_leaf + K). Smoothing moderates small counts but does not by itself guarantee calibrated probabilities after adaptive tree selection.

Numeric targets require numeric impurity

Regression trees commonly predict a leaf mean and choose splits reducing squared error, equivalently weighted within-node variance under consistent denominators. For targets 2, 4, 8, 10, the parent mean is six and population variance is ten. Splitting into {2,4} and {8,10} gives means three and nine, each with variance one. Weighted child variance is one, so variance reduction is nine. Absolute-error objectives instead naturally use leaf medians.

Stopping, pruning, and business use

Unrestricted trees can memorize training examples. High-cardinality attributes, such as nearly unique account identifiers, can create artificially pure groups and bias information gain toward unhelpful splits. Exclude unjustified identifiers, constrain leaves, consider alternative split criteria where appropriate, and verify generalization.

Pre-pruning stops growth using maximum depth, minimum leaf size, or minimum improvement. Post-pruning grows a larger tree and removes branches using validation or a complexity penalty. Node-level significance tests are not a universal fix: searching many candidate splits introduces selection and multiple-testing concerns. Tune complexity without repeatedly consulting the final test set; see validation.

Business users can audit paths and compare segment outcomes, but apparent rule simplicity does not make a relationship causal. Small data changes can produce different trees, and pure training leaves may be unstable. Ensembles such as random forests average multiple varied trees to reduce variance, often sacrificing the transparency of one compact tree.

Why not average child entropies without weights?

That treats children as equally common even when they contain different numbers of observations. Information gain averages uncertainty for an example drawn from the parent population.

Does a pure leaf establish 100% future probability?

No. It records observed training labels after adaptive selection. Sampling uncertainty, overfitting, and population change remain; smoothing and held-out evaluation are essential safeguards.

Compare with linear models and Bayesian evidence.

Definition

View in glossary →