Lab Assignment-8
Assignment-8- week 2 September
Learning Objective: Learn Decision Trees
Problem Statement
1.A college wants to predict whether a student will Pass or Fail in an examination based on three categorical attributes:
- Attendance – High / Low
- Study – Good / Poor
- Previous Result – Pass / Fail
The following training dataset is available:
| Student | Attendance | Study | Previous Result | Final Result |
|---|---|---|---|---|
| S1 | High | Good | Pass | Pass |
| S2 | High | Good | Fail | Pass |
| S3 | High | Poor | Pass | Pass |
| S4 | High | Poor | Fail | Fail |
| S5 | Low | Good | Pass | Pass |
| S6 | Low | Good | Fail | Fail |
| S7 | Low | Poor | Pass | Fail |
| S8 | Low | Poor | Fail | Fail |
| S9 | High | Good | Pass | Pass |
| S10 | Low | Good | Pass | Pass |
| S11 | High | Poor | Pass | Pass |
| S12 | Low | Poor | Fail | Fail |
Tasks
-
Calculate the entropy of the complete dataset with respect to the
Final Result. -
Calculate the Information Gain for each attribute:
- Attendance
- Study
- Previous Result
- Select the attribute having the highest Information Gain as the root node.
- Repeat the entropy and Information Gain calculations for the remaining subsets.
- Construct the complete decision tree using the ID3 algorithm.
- Represent the final decision tree graphically.
- Use the constructed tree to predict the result for the following new students:
| Student | Attendance | Study | Previous Result |
|---|---|---|---|
| A | High | Poor | Fail |
| B | Low | Good | Pass |
| C | Low | Poor | Pass |
| D | High | Good | Fail |
- Implement the same problem using Scikit-learn's decision tree classifier and compare the predictions with your manually constructed ID3 tree.
2.Implement a Decision Tree classifier using the ID3 algorithm to segment customers based on their purchasing behavior using the Online Retail dataset. Analyze the tree structure and discuss the feature importance.
Tasks:
- Load and preprocess the Online Retail dataset.
- Implement Decision Tree using the ID3 algorithm.
- Visualize the decision tree and analyze feature importance.
- Discuss how the tree structure helps in understanding customer behavior.
3.Implement and compare Logistic Regression and Decision Trees on the Adult Income dataset for predicting income levels. Evaluate both models based on performance metrics and interpretability.
Tasks:
- Load and preprocess the Adult Income dataset.
- Implement both Logistic Regression and Decision Trees.
- Compare the models based on metrics such as accuracy, precision, recall, and F1-score.
- Discuss the interpretability of both models and their suitability for the dataset.
Comments
Post a Comment