Implementation of Decision Tree using ID3 Algorithm with Visualization (scikit-learn)
Experiment
Title
Implementation of Decision Tree using ID3 Algorithm with Visualization
๐ฏ Objective
- To implement ID3 Decision Tree
-
To compute:
- Entropy
- Information Gain
- To visualize the decision tree
๐ Sample Dataset (Play Golf)
| Outlook | Temperature | Humidity | Windy | Play |
|---|---|---|---|---|
| Rainy | Hot | High | False | Yes |
| Rainy | Hot | High | True | No |
| Overcast | Hot | High | False | Yes |
| Sunny | Mild | High | False | No |
| Sunny | Cool | Normal | False | Yes |
| Sunny | Cool | Normal | True | No |
| Overcast | Cool | Normal | True | Yes |
| Rainy | Mild | High | False | No |
| Rainy | Cool | Normal | False | Yes |
| Sunny | Mild | Normal | False | Yes |
| Rainy | Mild | Normal | True | Yes |
| Overcast | Mild | High | True | Yes |
| Overcast | Hot | Normal | False | Yes |
| Sunny | Mild | High | True | No |
๐ Theory
๐น ID3 Algorithm
- Uses Entropy & Information Gain
- Builds tree top-down
- Greedy approach
๐ป Complete Python Program
๐ Output
๐ Observations
- Tree matches manual ID3 calculation
- Entropy-based splitting
- Pure nodes become leaves
๐งช Lab Tasks
Task 1
Change criterion:
Task 2
Limit depth:
Task 3
Test prediction:
๐ Key Insights
| Concept | Meaning |
|---|---|
| Entropy | Impurity |
| Gain | Feature selection |
| Leaf node | Final decision |
Result
-
ID3 builds tree using:
- Entropy
- Information Gain
- Easy to interpret
- Works well for categorical data

Comments
Post a Comment