Skip to main content

Overfitting and pruning

Short answer

Overfitting occurs when a model fits training noise, giving low training error but high test error. Avoid it by pruning, using more and cleaner data, limiting model depth, or cross-validation. Pre-pruning stops tree growth early if a split is not good enough, while post-pruning grows the full tree and then replaces subtrees with leaves when error does not increase; pre-pruning is faster but may underfit, and post-pruning is usually more accurate.

What do you mean by overfitting? What are approaches to avoid it? Differentiate Pre-pruning and Post-pruning.

Overfitting occurs when a model fits the training data too closely, including noise and chance patterns, so it has very low training error but a high error on unseen (test) data. In a decision tree it appears as a very large tree with many branches that reflect noise or outliers. Causes: noisy data, too few training records, and a too complex model.

Approaches to avoid overfitting

  • Pruning (pre- and post-).
  • Use a larger and cleaner training set; remove noise and outliers.
  • Limit the model: maximum depth, minimum records per node, minimum gain.
  • Use a validation set or cross-validation to select the model size.
  • Use the MDL principle (prefer the model with the shortest total description length).
  • Use ensembles (bagging, random forest).

Pre-pruning vs post-pruning

BasisPre-pruning (early stopping)Post-pruning
WhenDuring tree constructionAfter the full tree is grown
MethodStop splitting if gain/records/purity fall below a thresholdReplace subtrees by leaves if error does not increase
Tree sizeNever grows the full treeGrows the full tree first
CostCheaper, fasterMore computation
RiskUnderfitting; stopping too early may miss a good later split (horizon effect)Wasted effort on growing branches later cut
AccuracyUsually less accurateUsually more accurate and preferred
ExamplesMinimum support, χ² test, max depthReduced-error pruning, cost-complexity pruning (CART), pessimistic pruning (C4.5)

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Mining chapter 3 questions →