Pruning limits a decision tree’s complexity by removing branches or preventing them from growing. Its purpose is to reduce overfitting: splits that add little predictive value can make a tree harder to interpret without helping it generalize to unseen data. section 6.3.2
One practical approach is to constrain growth during fitting rather than trim a completed tree. Setting max_depth=3 limits how deep the classifier can split. This is a depth limit, not a separate statistical-significance test of each branch; the split criterion, such as Gini impurity or entropy, serves a different purpose. section 6.3.2
>>> from sklearn.tree import DecisionTreeClassifier >>> clf = DecisionTreeClassifier(criterion = 'gini', \ >>> max_depth = 3, random_state = 0)
This scikit-learn configuration caps tree depth at three, chooses Gini impurity to evaluate splits, and fixes the random seed for reproducibility. Fit the configured classifier on X_train and y_train, then make predictions on the unseen test subset. section 6.3.2
A smaller tree is easier to trace from feature conditions to a predicted class, but simplicity alone does not establish predictive accuracy. Inspect the plotted splits and assess predictions on data withheld from fitting. Pruning removes splits and features, not training records: observations remain assigned to nodes in the resulting tree. section 6.3.2 section 6.3.6
Fourth-down conversion tree
A depth-limited classifier predicts whether a fourth-down attempt converts. Its plotted nodes show conditions such as TO_GO <= 3.5, sample counts, class counts, and predicted classes. The resulting tree has fewer splits and features than an unrestricted version would have, making its decision paths more manageable to inspect. section 6.3.5 section 6.3.6
Pruning addresses one weakness of decision trees, but it is not a complete remedy: trees can still be unstable when data changes or perform poorly on imbalanced data without appropriate tuning. A random forest is another option for mitigating some single-tree disadvantages. section 6.3.7






