Posts

Showing posts with the label ID3

Decision Tree Classification _ Program

Q.  Decision Tree Classification Problem Description As you know, Decision Tree is all about splitting nodes at different levels and trying to classify accurately as much as possible. You are given a feature (1-d array) and label (1-d array) (target) where you have to determine which value in the corresponding feature is best to split upon at the first root level for building a decision tree. The feature would be having continuous values whereas the target is binary in nature. So, The main task is to determine which value/threshold is best to split upon considering the classification task taking the loss as entropy and maximizing Information Gain. Input Format Two inputs: 1. 1-d array of feature 2. 1-d array of label Output Format Return threshold value Example Input feature: [0.58 0.9  0.45 0.18 0.5  0.12 0.31 0.09 0.24 0.83] label: [1 0 0 0 0 0 1 0 1 1] Example Output 0.18 Example Explanation If you calculate Information Gain for all of the feature values, it would be computed as : (