Question

AAI/CPE/EE 695 Applied Machine Learning: Homework #3 For questions 1-4, please submit a *.pdf file via Canvas. For question 5, please submit a *.ipynb file via Canvas. Written Response Question(s):

1. Explain the bias-variance tradeoff. Describe a few techniques to reduce bias and variance respectively. 2. Assume the following is the confusion matrix of a classifier. Calculate the following metrics for this classifer: D3 D4 D5 a. Precision b. C. D6 D7 D8 D9 D10 Recall F1-Score OUTLOOK Sunny Sunny Overcast Rain Rain 3. Build a decision tree using the following training instances (using the information gain approach): DAY HUMIDITY D1 High D2 High Rain Overcast Sunny Sunny Rain Predicted Results Class 1 True 50 Class 1 values Class 2 40 TEMPERATURE Hot Hot Hot Mild Cool Cool Cool Mild Cool Mild Class 2 30 60 Spring 2024 High High Normal Normal Normal High Normal Normal WIND Weak Strong Weak Weak Weak Strong Strong Weak Weak Weak PLAYTENNIS No No Yes Yes Yes No Yes No Yes Yes 4. The naïve Bayes method is an ensemble method, as we learned in Lecture 5. Assume we have three classifiers, and their predicted results are given in Table 4.1. The confusion matrix of each classifier is given in Table 4.2. Calculate the final decision using the Naïve Bayes method: Table 4.1 b) Classifier 1 Class 1 40 30 Class 1 Class 2 Class 2 10 20 Sample x Classifier 1 Classifier 2 Classifier 3 1 Class 1 Class 2 age 1.5 a) Classifier 2 Class 1 20 20 0 Result Class 1 Class 1 Class 2 Table 4.2 pclass: 3rd sibsp<1.5 Programming Problem(s): 5. Use decision tree and random forest to train models using the titanic.csv dataset included in this assignment. Step 1: Read titanic.csv and observe a few samples, noting that there are both categorical and numerical features. If some features are missing, fill them in using the average of the same feature of other samples. Take a random 80% of samples for training and use the remaining 20% for testing. 0 Step 2: Fit a decision tree model using independent variables "pclass + sex + age + sibsp" and dependent variable "survived." Plot the full tree. Make sure “survived” is a qualitative variable taking 1 (yes) or 0 (no) in your code. You may see a tree similar to this one, but the actual structure and size may vary: sex: female Class 30 30 sibsp<2.5 0 age < 14.25 pclass: 2nd, 3rd age 32.5 c) Classifier 3 Class 1 50 40 0 Class 1 Class 2 0 Class 2 0 10 0 Step 3: Use the GridSearchCV() function to find the best value for the parameter max_leaf_nodes to prune the tree. Plot the pruned tree, which will be smaller than the tree you obtained in Step 2. Step 4: For the pruned tree, report its accuracy on the test set for the following: 1. Percent survivors correctly predicted (on test set) 2. Percent fatalities correctly predicted (on test set) Step 5: Use the RandomForestClassifier() function to train a random forest using the value of max_leaf_nodes you found in Step 3. You can set n_estimators-50. Report the accuracy of the random forest on the test set for the following: 1. Percent survivors correctly predicted (on test set) 2. Percent fatalities correctly predicted (on test set) Check whether the random forest improves on the results of the single tree from Step 4.