Assignment Chef icon Assignment Chef

[Solved] CS434 assignment 3-Decision Tree Ensemble for Predicting Election Results by US County Statistics

5.0 1 customer review Digital download

Digital download

$25.00

Availability
In stock
Checkout
One item

Need a hand?

Message us on WhatsApp for payment or download support.

WhatsApp QR code
In this assignment we will work on a task to classify United States counties between Democratic and Republican majority vote in the 2016 US Election. We do this based on a set of discrete features related to each county. These features are a categorical representation of continuous features, which are provided in the data description (county dictionary) file. The goal in this assignment is to develop variations of the decision tree algorithm and ensemble methods. Data. The data for this assignment is taken from a collection of US election data in the primary elections from 2016. The data has already been preprocessed for you. Here is a short description of each train and validation split: Important Guidelines. For all parts of this assignment: Part 1 : Decision Tree (DT). For this part we are interested in using a decision tree with below configuration: list A to two left and right list AL and AR as depicted in figure 1 then Figure 1: Split according to feature fi testing against value v the benefit of split for feature fi against value v is computed as: B = U(A) plU(AL) prU(AR) (1) Where U is the uncertainty measure. For this assignment, we will use gini-index, which is computed for a list such as AL as follows: (2) and pl and pr are the probabilities for each split which is given by (3) Please implement the following steps: Part 2 : Random Forest (Bagging). In this part we are interested in random forest which is a variation of bagging without some of its limitations. Please implement the following steps: Here is how the forest is created: The random forest is a collection of n trees trees. All the trees in the forest have maximum depth of max depth. Each tree is built on a data set of size 2098 (size of your original training data) sampled (with replacement) from the training data. You sample both X and y together and need to preserve the indexes that correspond to (X, y) pairs. In the process of building a tree of the forest, each time we try to find the best feature fi to split, we need to first sub-sample (without replacement) max features number of features from the feature set and then pick fi with highest benefit from max features sampled features. Much of this is handled already in your DecisionTreeClassifier, but you need to modify DecisionTreeClassifier class to handle feature bagging. You will also fill in missing RandomForestClassifier code in this class. Part 3 : AdaBoost (Boosting). For this part we are interested in applying AdaBoost to create yet another ensemble model with decision trees. Considering the AdaBoost algorithm described in the slides, please do following steps: (Hint: It changes the probability estimation used for computing gini-impurity and also for the predictions at leaves, use majority weights instead of majority counts. Basically, your weight vector D dictates your predictions, rather than majority class). Part 4 : Class Imbalance Questions Here, I hope youve noticed that with a 2:1 ratio of positive to negative class (approximately 66% of the data is class 1), accuracy might not be the best thing to report. Basically, were used to seeing data with 50% for each class, and we know were doing well if we get better than random guessing, which we can see immediately with accuracy. In this class imbalanced case, we could predict the positive class every time and have a base accuracy of approximately 66%, which might trick us into thinking our model is doing okay. Weve done nothing to handle this imbalance while training, but there are many things that are often done, and theres not a right answer for every case. What you need to do here is the following: