ArticleslgStudy

computer science

Decision tree pruning

Decision tree pruning is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Decision tree pruning rather than just read about it. In short: Pruning is a data compression technique in machine learning and search algorithms that reduces the size of decision trees by removing sections of the tree that are non-critical and redundant to classify instances. Pruning reduces the complexity of the final classifier, and hence improves predictive accuracy by the reduction of overfitting.

Decision tree pruning — main illustration
Decision tree pruning — illustration

Key takeaways

  • Decision tree pruning belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Decision tree pruning to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Decision tree pruning from memory before moving on to harder problems.

Reference excerpt

Pruning is a data compression technique in machine learning and search algorithms that reduces the size of decision trees by removing sections of the tree that are non-critical and redundant to classify instances. Pruning reduces the complexity of the final classifier, and hence improves predictive accuracy by the reduction of overfitting. One of the questions that arises in a decision tree algorithm is the optimal size of the final tree. A tree that is too large risks overfitting the training data and poorly generalizing to new samples. A small tree might not capture important structural information about the sample space. However, it is hard to tell when a tree algorithm should stop because it is impossible to tell if the addition of a single extra node will dramatically decrease error. This problem is known as the horizon effect. A common strategy is to grow the tree until each node contains a small number of instances then use pruning to remove nodes that do not provide additional information. Pruning should reduce the size of a learning tree without reducing predictive accuracy as measured by a cross-validation set. There are many techniques for tree pruning that differ in the measurement that is used to optimize performance.

Techniques Pruning processes can be divided into two types (pre- and post-pruning). Pre-pruning procedures prevent a complete induction of the training set by replacing a stop () criterion in the induction algorithm (e.g. max. Tree depth or information gain (Attr)> minGain). Pre-pruning methods are considered to be more efficient because they do not induce an entire set, but rather trees remain small from the start. Prepruning methods share a common problem, the horizon effect. This is to be understood as the undesired premature termination of the induction by the stop () criterion. Post-pruning (or just pruning) is the most common way of simplifying trees. Here, nodes and subtrees are replaced with leaves to reduce complexity. Pruning can not only significantly reduce the size but also improve the classification accuracy of unseen objects. It may be the case that the accuracy of the assignment on the train set deteriorates, but the accuracy of the classification properties of the tree increases overall. The procedures are differentiated on the basis of their approach in the tree (top-down or bottom-up).

Bottom-up pruning These procedures start at the last node in the tree (the lowest point). Following recursively upwards, they determine the relevance of each individual node. If the relevance for the classification is not given, the node is dropped or replaced by a leaf. The advantage is that no relevant sub-trees can be lost with this method. These methods include Reduced Error Pruning (REP), Minimum Cost Complexity Pruning (MCCP), or Minimum Error Pruning (MEP).

Top-down pruning In contrast to the bottom-up method, this method starts at the root of the tree. Following the structure below, a relevance check is carried out which decides whether a node is relevant for the classification of all n items or not. By pruning the tree at an inner node, it can happen that an entire sub-tree (regardless of its relevance) is dropped. One of these representatives is pessimistic error pruning (PEP), which brings quite good results with unseen items.

Pruning algorithms

Reduced error pruning One of the simplest forms of pruning is reduced error pruning. Starting at the leaves, each node is replaced with its most popular class. If the prediction accuracy is not affected then the change is kept. While somewhat naive, reduced error pruning has the advantage of simplicity and speed.

Cost complexity pruning Cost complexity pruning generates a series of trees ⁠T0…Tm⁠ where ⁠T0⁠ is the initial tree and ⁠Tm⁠ is the root alone. At step ⁠i⁠, the tree is created by removing a subtree from tree ⁠i−1⁠ and replacing it with a leaf node with value chosen as in the tree building algorithm. The subtree that is removed is chosen as follows:

Define the error rate of tree ⁠T⁠ over data set ⁠S⁠ as ⁠err⁡(T,S)⁠. The subtree t that minimizes err⁡(prune⁡(T,t),S)−err⁡(T,S)|leaves⁡(T)|−|leaves⁡(prune⁡(T,t))| is chosen for removal. The function ⁠prune⁡(T,t)⁠ defines the tree obtained by pruning the subtrees ⁠t⁠ from the tree ⁠T⁠. Once the series of trees has been created, the best tree is chosen by generalized accuracy as measured by a training set or cross-validation.

Examples Pruning could be applied in a compression scheme of a learning algorithm to remove the redundant details without compromising the model's performances. In neural networks, pruning falls into two broad categories. Unstructured pruning removes individual weights or connections, typically those below a chosen magnitude threshold, producing a sparse weight matrix. While this can dramatically reduce parameter count, the irregular pattern of remaining weights makes it difficult to accelerate on standard hardware. Structured pruning, by contrast, removes entire neurons, channels, filters, or layers, producing a smaller but still dense network that is easier to accelerate on conventional hardware, though it is generally more difficult to achieve high sparsity ratios without degrading accuracy. A common workflow is train-prune-fine-tune: a network is first trained to convergence, pruned according to a chosen criterion, and then fine-tuned for a few additional epochs at a low learning rate to recover any accuracy lost during pruning. This process may be repeated iteratively, with the pruning rate increased at each round.

See also Alpha–beta pruning Artificial neural network Null-move heuristic Pruning (artificial neural network)

References Pearl, Judea (1984). Heuristics: Intelligent Search Strategies for Computer Problem Solving. Addison-Wesley. ISBN 978-0-201-05594-8. Mansour, Y. (1997). "Pessimistic decision tree pruning based on tree size". Proc. 14th International Conference on Machine Learning. pp. 195–201. Breslow, L. A.; Aha, D. W. (1997). "Simplifying Decision Trees: A Survey". The Knowledge Engineering Review. 12 (1): 1–47. doi:10.1017/S0269888997000015. S2CID 18782652. Quinlan, J. R. (1986). "Induction of Decision Trees". Machine Learning. 1. Kluwer: 81–106. doi:10.1007/BF00116251.

Further reading MDL based decision tree pruning Archived 2017-08-29 at the Wayback Machine Decision tree pruning using backpropagation neural networks

… excerpt ends here. Continue reading the full article.

Illustrations

Decision tree pruning: Before and after pruning
Before and after pruning

Worked examples

Example 1 — a first encounter with Decision tree pruning

Start with the simplest possible case. Write down what Decision tree pruning claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Decision tree pruning before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Decision tree pruning ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Decision tree pruning

In research
Decision tree pruning appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Decision tree pruning in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Decision tree pruning is common in secondary-school and first-year university syllabi. It links to neighbouring topics Decision trees, Machine learning, so understanding it makes those chapters shorter.
In everyday life
Look for Decision tree pruning outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Decision tree pruning” →

How to study Decision tree pruning in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Decision tree pruning means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Decision tree pruning out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Decision tree pruning in simple terms?

Pruning is a data compression technique in machine learning and search algorithms that reduces the size of decision trees by removing sections of the tree that are non-critical and redundant to classify instances. Pruning reduces the complexity of the final classifier, and hence improves predictive…

Why does Decision tree pruning matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Decision tree pruning?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Decision tree pruning.

Tags

  • Decision trees
  • Machine learning

Keep exploring