Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

PROBLEM SET 3

PPOL 565

Submission Instructions   For this assignment, you will include both code and responses to questions in a Jupyter notebook.   Python code should be thoroughly commented and executed in code cells and all text should be placed in Markdown cells with proper formatting. Use Markdown headings to indicate each section of code  (Part  1,  Part 2, etc.).   Before submitting your notebook on Canvas, run all cells in the notebook and export it as an HTML file. The lename should end with your Georgetown NetID (e.g., pset3_netID.html).

Reminders:   Code must run without errors.  Scripts that produce errors will receive zero points for those sections.  For full credit, code must be free of semantic errors, be written with liberal comments, include meaningful variable names, and use control structures to minimize repetition (three or more instances of nearly identical statements) except where instructed.

Part 1

Consider the training examples shown in the table below for a binary classication problem.

Instance

1

2

3

Target Class

1

T

T

1.0

+

2

T

T

6.0

+

3

T

F

5.0

4

F

F

4.0

+

5

F

T

7.0

6

F

T

3.0

7

F

F

8.0

8

T

F

7.0

+

9

F

T

5.0

1. What is the entropy of this collection of training examples with respect to the positive class?

2. What are the information gains of a1  and a2  relative to these training examples?

3. For a3 , which is a continuous attribute, compute the information gain for every possible split.  (Hint: Sort the instances by a3  and compute the split point as the midpoint for each interval.) Determine the best split point.

4. What attribute provides the the best split (among a1 , a2 , and a3 ) according to the information gain?

5. What attribute provides the best split (between a1 and a2 ) according to the Gini index?

Part 2

Each weekday, the Federal Trade Commission publishes a list of Do Not Call and robocall complaints. The dataset donotcall.csv can be downloaded from Canvas.

1. Examine the dataset and discuss the following:

(a) Attribute types

(b) Resolution and possible alternative units of analysis

(c) Dimensionality

(d) Missing values

2.  Create a variable called  same   area   code which has a value of 1 if the caller and

consumer have the same area code, and 0 otherwise.

3. Assess and drop missing values.  Create a target array for is_robocall and a feature matrix including only subject and same_ area_ code. Encode the target variable values using LabelEncoder().

4. In the feature matrix, convert the subject variable to a set of dummy variables for each category.  The resulting feature matrix should have a variable for each of the subject types (Charities, Debt collection, etc.) and no longer include the variable subject.

5. Fit a decision tree classifier using the entire set of observations.  Evaluate the per- formance of the model using ve-fold cross-validation.  What is the mean accuracy score?

6.  Construct a validation curve to assess performance for a maximum tree depth ranging from 1 through 10. What tree depth would you select, based on the validation curve?

7.  Split the data into training and test sets, holding out 20% of the data for testing. Fit a decision tree classifier with the training data using the maximum depth you selected from part 2.6. What is the accuracy score for the test data?

8.  Construct a confusion matrix for the model in part 2.7.  Which type of classification error is most prevalent?

9. Plot the decision tree. Provide an interpretation of the plot.