Decision Tree Interview Q&A
1. Disadvantages of Decision Trees:
Overfitting: common problem with Decision Trees.
High variance: due to overfitting, there is more likely a chance of high variance in output which leads to many errors in final predictions and shows high inaccuracy in results. So, in order to achieve zero bias (overfitting), it leads to high variance due to bias-variance tradeoff.
Unstable: adding new data points DT can lead to regeneration of overall tree. so all nodes need to be recalculated and reconstructed
Not good if dataset is large: single tree may grow complex and lead to overfitting in this case, we should use Random Forest instead, an ensemble technique of a single Decision Tree.
2. Advantages of Decision Trees:
Easy to understand & Clear Visualisation: DT is simple to interpret and visualise, dt idea is mostly used in our daily lives.
Feature Scaling not Required: standardisation and normalisation in case of Decision Tree not required, as DT uses a rule-based approach instead of calculation of distances
Handles Nonlinear parameters efficiently: Unlike curve-based algorithms, performance of decision trees can’t be affected by Non-linear parameters.
Can automatically handle Missing Values
Handles Outliers Automatically usually robust to outliers
Less Training Period training period of decision trees is less as compared to ensemble techniques like Random Forest because it generates only one tree unlike forest of trees.
3. Cases where Decision Trees are most suitable
In healthcare industries:
In banking sectors:
In educational Sectors :
4. Decision Tree handles continuous(numerical) features
5. Feature Selection using Information Gain/Entropy Technique
6. Attribute selection measures
Information Gain: biased towards multivalued attributes
Gain ratio: prefers unbalanced splits in which one data segment is much smaller than other segment
Gini Index: biased to multivalued attributes, has difficulty when number of classes is large, tends to favour tests that result in equal-sized partitions and purity in both partitions
7. Requirement in Pruning in Decision Trees
8. Types of Pruning in a Decision Tree
When we remove sub-nodes of a Decision node, this process is called pruning or opposite process of splitting.
Two techniques which are widely used for pruning are - Post and Pre Pruning
Post Pruning:
Pre Pruning:
Recommended by LinkedIn
9. Properties of Gini Impurity
Let X (discrete random variable) takes values ₊ve and ₋ve (two classes). Now, let’s consider different cases:
Case- 1: When 100% observations belong to ₊ve . Then, Gini impurity of system would be: – Gin(x) = 1 - (1^2 + 0^2) = 0
Case- 2: When 50% observations belong to y₊ . Then, the Gini impurity of the system would be: – Gin(x) = 1 - (0.5^2 + 0.5^2) = 0.5
Case- 3: When 0% observations belong to ₊ve . Then, Gini impurity of the system would be: – Gin(x) = 1 - (0^2 + 1^2) = 0
10. Disadvantages of Information Gain
11. Decision Tree handling missing values
Decision Trees handle missing values in following ways:
12. Decision Tree handling continuous(numerical) features
13. Inductive Bias of Decision Trees
14. CART and ID3 difference
15. Gini impurity and Entropy which one to prefer
16. Reasons why decision tree accuracy may go low
Bad Data :- very important to use correct data for machine learning algorithms
Randomness :- most of time system is so complex that it is impossible to predict what will happen in future. In such cases, accuracy of decision tree will drop as well
Overfitting :- DT may not be able to capture uniqueness of data, and so it can be considered as a generalisation. If same data is used to adjust tree, it can over-fit data
17. Improving decision tree
18. Linear Regression and Decision Trees comparison
19. Greedy Splitting or Recursive Binary Splitting procedure
20. Post-pruning & Pre-pruning(early-stopping) methods
Pruning involves cutting back tree. After a tree has been built, it might overfit data. There are many ways to prune a tree, some of which are:
Pre-pruning is also known as early-stopping. overfitting of data may also be prevented by stopping tree-building process early (before it produces leaf nodes with very small samples). Pre-pruning can under-fit data by stopping too early. Method to pre-prune a tree:
🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆
Happy Learning😊