One solution to the problem of overfitting is pruning. Pruning is a technique in which the tree is not grown to its full size, but instead is only allowed to grow to a certain depth. Exhibit 11-12 shows the decision tree from the previous example grown to a depth of three layers.

The diagram shows three layers of the tree. The details of the diagram are as follows:
The credit score with a value of 675 is at Cut 1. The 13 dots with credit scores higher than 675 are on the right, to R1, while the 11 dots with credit scores less than 675 are on the left, to R2. The node of R2 is labeled as cut 3 with an income of 85,000 dollars. The nine borrowers in R5 with incomes below 85,000 dollars move to the left to default. The two borrowers in R6 with incomes higher than 85,000 dollars move right to repayer.
The node of R1 is labeled as cut 2 with an income of 56,000 dollars. At the first node, the 10 borrowers whose income is greater than 56,000 dollars go to the right, while the three borrowers whose income is less than 56,000 dollars go to the left.
The node of R3 is labeled as cut 4 with a credit of 768. The two borrowers in R7 with credit below 768 move to the left to default. The one borrower in R8 with credit higher than 768 move right to repay. The node of R4 is labeled as cut 5 with a credit of 712. A dashed line labels the level as pruning at depth 3. The ten borrowers in R10 with credit above 712 move to the right to repayer. The three borrower in R9 with credit below 712 move left to 2 repayers and 1 defaulter.
If we prune the tree to a depth of three layers, we get the following tree and rule for defaulters:
If the borrower’s features do not satisfy any of these conditions, then .
The first two rules for classifying defaulters in the pruned tree are identical to the rules for classifying defaulters in the fully grown tree (also called full tree). The third rule is different. Pruning creates one impure node in the lower right part of the tree, as shown in Exhibit 11-12. Of the three borrowers whose credit scores are less than 712, two borrowers at that node are repayers and one is a defaulter. Without purity in the node, the model classifies the three borrowers in probabilistic terms. When a borrower’s credit score is less than 712 but greater than 675, and income is greater than $56,000, the pruned decision tree model indicates there is a 1/3 probability of a borrower defaulting (1 default loan out of 3 total loans).
Building models by pruning trees raise two questions: (1) To what depth should the tree be pruned? For example, why not prune the tree up to depth 2 rather than depth 3? (2) How can a data scientist compare trees when there are thousands of data points and hundreds of features? In some contexts, as was the case in the prior example, the management accountant can use his or her understanding of the economics of a business to recognize overfitting, but in other, more complex models with many features, this may be more difficult. To choose among models and to decide where to prune, data scientists cross-validate the model. The management accountant uses his or her business knowledge to interpret and evaluate the selected model.