To find a balance between the tree's error rate and its complexity.
To directly minimize the training error, R(T), regardless of tree size.
To maximize the number of terminal nodes, |T|, while keeping the error rate, R(T), constant.
To calculate the Gini impurity for each potential split in the tree.
The tree will become simpler, with fewer terminal nodes.
The tree will become more complex, with more branches.
The tree's structure will remain unchanged, but its error rate will decrease.
The value of alpha has no impact on the final tree structure.
t
The total error of the subtree rooted at node t.
The alpha value at which pruning the subtree TtT_tTt becomes more cost-effective than keeping it.
The improvement in Gini impurity achieved by node t.
The number of leaves in the subtree TtT_tTt minus one.
True
False
The sequence is ordered by increasing training error.
It is a nested sequence where each tree is a subtree of the one before it.
Each tree in the sequence is generated by randomly removing a node.
The sequence contains trees of all possible sizes, from the full tree down to the root node.
By choosing the smallest tree in the sequence (the root node).
By using k-fold cross-validation to find the subtree (and its corresponding alpha) with the best performance on unseen data.
By selecting the tree that corresponds to the median alpha value in the sequence.
By picking the subtree with the lowest training error.
The model corresponding to an alpha value of exactly 1.0.
The model with the absolute lowest cross-validation error.
The simplest model whose error is within one standard error of the minimum error.
The largest possible model whose error is still below a predefined threshold.
decreases; decreases
increases; increases
increases; decreases
decreases; increases
max_depth
Both methods are guaranteed to find the same optimal pruned tree.
Post-pruning can find a better trade-off because it evaluates the full tree before deciding which branches are least valuable.
Pre-pruning is superior because it prevents the tree from growing too large in the first place, saving computation.
cost_complexity_pruning_path
DecisionTreeClassifier
nodes and errors
nodes
errors
max_depths and min_samples_leaf
max_depths
min_samples_leaf
feature_importances_ and scores
feature_importances_
scores
ccp_alphas and impurities
ccp_alphas
impurities
ccp_alpha
Use the optimal ccp_alpha to set the max_depth of a new tree.
Manually remove nodes from the original tree.
The tree associated with the optimal ccp_alpha is automatically saved and requires no further action.
Train a new DecisionTreeClassifier on the full training data, setting the ccp_alpha parameter to your optimal value.
All done? Get your grade