What is pruning and How to do pruning in Decision trees



I understood what is decision trees and how it works with help of Sunil Sir’s article http://www.analyticsvidhya.com/blog/2015/01/decision-tree-algorithms-simplified/#comment-102870

I couldnt understand What is Pruning and how to do it in decision trees.

Can anyone help me with that please.



Pruning is a process of removing the parts of the tree which adds very little to the classification power of the tree.
Pruning is done with two things in mind :slightly_smiling

  1. Reducing the complexity
  2. Reducing the chances of overfitting

Prune function are avalable in R which helps you prune a decision tree n R


Hello @Rohit_Nair,

To add to what @ashwinikumar081 has said,if you are using R:

model.rpart <- rpart(promotion_name ~ .,data = training_imp_var,method = "class")
#See cross validation results:
#Prune the tree:
pruned.tree <- prune(model.rpart, cp = model.rpart$cptable[which.min(model.rpart$cptable[,"xerror"]),"CP"])  

This can be used to prune the tree based on the minimum value of cp which makes the error of the decision tree minimum.

Hope this helps!!