How does pruning a tree work?

Pruning refers to the process of simplifying a decision tree after it has already been created by removing leaf nodes that result in the smallest information gain. This technique can be useful in preventing overfitting to the training data, especially if some of the leaves contain a small number of observations. Alternatively, hyperparameters such as the maximum depth or minimum number of observations per leaf node can be tuned during model selection to accomplish a similar purpose.