How does cost-complexity (weakest-link) pruning work?

Quick Overview

Asks how CART's cost-complexity pruning trades training error against tree size and how weakest-link pruning builds a sequence of subtrees. Tests the effective alpha of a node, choosing alpha by cross-validation, and why pruning a grown tree can beat early stopping.

How does cost-complexity (weakest-link) pruning work?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

How does cost-complexity (weakest-link) pruning work? ```hint A penalized objective Write an objective that adds a per-leaf penalty to the training error, then ask at what penalty value collapsing one particular subtree into a leaf stops costing anything. ``` ```hint Follow the penalty upward As the penalty grows from zero, think about the sequence of trees you get and how you would pick one of them. ``` ### What a Strong Answer Covers - The penalized objective and what each of its terms measures - How a node's effective alpha is computed and what it means - The pruning loop and the nested sequence of subtrees it produces - How the final alpha, and so the final tree, is chosen - Why pruning a grown tree can beat stopping the growth early ### Follow-up Questions - How do you cross-validate alpha when each fold's tree produces a different alpha sequence? - What does the 1-SE rule trade away, and when would you use it? - Would you apply cost-complexity pruning to the trees inside a random forest or a gradient boosting model? - In scikit-learn, what units is `ccp_alpha` measured in?

Overview: Asks how CART's cost-complexity pruning trades training error against tree size and how weakest-link pruning builds a sequence of subtrees. Tests the effective alpha of a node, choosing alpha by cross-validation, and why pruning a grown tree can beat early stopping.

General logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

How does cost-complexity (weakest-link) pruning work?

What a Strong Answer Covers Guidance

  • The penalized objective and what each of its terms measures
  • How a node's effective alpha is computed and what it means
  • The pruning loop and the nested sequence of subtrees it produces
  • How the final alpha, and so the final tree, is chosen
  • Why pruning a grown tree can beat stopping the growth early

Follow-up Questions Guidance

  • How do you cross-validate alpha when each fold's tree produces a different alpha sequence?
  • What does the 1-SE rule trade away, and when would you use it?
  • Would you apply cost-complexity pruning to the trees inside a random forest or a gradient boosting model?
  • In scikit-learn, what units is ccp_alpha measured in?