### Our Services

Get 15% Discount on your First Order

# check the attachements Please read the instructions and questions carefully in ” Assignment_4_2023_Fall.pdf” file and use “Auto.csv” to

check the attachements

Please read the instructions and questions carefully in ” Assignment_4_2023_Fall.pdf” file and use “Auto.csv” to finish the assignment. You should submit both 1) an R code ; 2) A PDF report with answers through the link “Submit Assignment 4 Here”

Guidelines:

· Use only R for this assignment

· Submit both R code and Report on findings

· Work is to be done individually for this assignment

Fitting a Classification Tree

1.
This problem involves the OJ data set which is part of the ISLR package (
Hint: the first three lines of codes should be: library (tree), library (ISLR), attach (OJ)).

1.1 Create a training set containing a random sample of 800 observations, and a test set containing the remaining observations. Take a screenshot of your code. (Hint: set.seed (2), train=sample())

1.2 Fit a tree to
the training data, with
Purchase as the response and the other variables as predictors. Use the summary( ) function to produce summary statistics about the tree. Take a screenshot of the summary statistics. How many terminal nodes does the tree have? What is the training misclassification error rate?

1.3 Plot the tree and take a screenshot of the tree (Hint: plot() and text())

1.4 Predict the response on the test data, and produce a confusion matrix comparing the test labels to the predicted test labels. What is the accuracy rate?

1.5 Apply the cv.tree() function to the training set in order to determine the optimal tree size. (Use set.seed(7)). Print the results (Hint: the results should contain the size, k, method etc).

1.6 Produce a plot with tree size (i.e. size) on the x-axis and cross-validated classification error rate (i.e. dev) on the y-axis.

1.7 Which tree size corresponds to the lowest cross-validated classification error rate (i.e. dev)?

1.8 Produce a pruned tree corresponding to the optimal tree size obtained using cross-validation. Take a screenshot of a pruned tree. What is the accuracy rate for the pruned tree? Is it improved compared to the accuracy rate in (1.4)?

1.9 If cross-validation does not lead to selection of a pruned tree (i.e. the accuracy rate produced in (1.8) is lower than the one in (1.4)), then create a pruned tree with five terminal nodes. What is the accuracy rate now?

1

Fitting a Regression Tree

2.
In the lab, a classification tree was applied to the Carseats data set after converting Sales into a qualitative response variable. Now we will seek to predict Sales using regression trees and related approaches, treating the response as a quantitative variable.

2.1 Using the validation-set approach to split the data set into a training set and a test set (Hint:
use set.seed(2); validation-set approach: half of the observations are selected as the training dataset while half of observations are treated as the test dataset). Take a screenshot of your code.

2.2 Fit a regression tree to the training set.

a) Use summary () to print out the results. How many terminal nodes do you get? What is RMD (Residual Mean Deviance)?

b) Plot the tree and take a screenshot of the tree;

c) What test MSE do you obtain?

2.3 Use cross-validation in order to determine the optimal level of tree complexity (use set.seed(2)).

a) Produce a plot with tree size on the x-axis and cross-validated classification error rate on the y-axis.

b) What is the optimal level of tree complexity?

c) Using the optimal level of tree size to prune the tree, does pruning the tree improve the test MSE?

2.4 Use the bagging approach in order to analyze this data. Take a screenshot of the results. What test MSE do you obtain? (Hint: use set.seed (1);
mtry=10 since we have 10 predictors in Carseats dataset and we use all of the predictors in the bagging approach).

2.5 Use random forests to analyze this data.

a) What test MSE do you obtain? (Hint: use set.seed(1);
mtry=10/3 since we usually use 1/3 of the predictors when building a random forest of regression trees)

b) Use the importance() function to determine which variables are most important. Take a screenshot of your results.

c) Plots of these importance measures can be produced using the varImpPlot() function. Take a screenshot of your output.

d) So which variables are most important?

What to submit:

1. R code.

a.

b.

c.

d.

2. Report.

a.

b.

c.

d.

e.

Should include all the code to accomplish the tasks.

Clear and concise comments to indicate what part of the assignment each code chunk pertains to.

Filename should be in the format of: LastnameFirstname_A4.R

Take screenshots of your outputs in R Studio and answer all the questions. Submit in PDF format.

Includes appropriate plots. Make sure the plots are properly labeled.

The assignment will be graded on the correctness of the answers, comprehensiveness of the analysis, clarity of results’ presentation and neatness of the report.

Order a Similar Paper and get 15% Discount on your First Order

## Related Questions

### After the Executive Committee’s meeting, Peter Joseph, the President, and CEO of Container Manufacturing Solutions (CMS) was contented with the briefing

After the Executive Committee’s meeting, Peter Joseph, the President, and CEO of Container Manufacturing Solutions (CMS) was contented with the briefing that you made on how enterprise architecture can help the organization. Mr. Joseph is now interested in the risks involved in creating an EA. He wants you to prepare

### Please write a reflection summary of what you have learned these past 16 weeks in the course “Physical Security” Also, tell me what things I did as an in

Please write a reflection summary of what you have learned these past 16 weeks in the course “Physical Security” Also, tell me what things I did as an instructor that were the most helpful to you, as well as any suggestions you have for further improving this course. Thank you, and I

### Perform a LOPA (Layers of Protection Analysis) of your local living area or work location. Remember to get permission from security.

Perform a LOPA (Layers of Protection Analysis) of your local living area or work location. Remember to get permission from security.

### 4/18/24, 11:38 AM Assignment Information 1/3 IT 200 Project Two The IT Professional Guidelines and Rubric Competency In this project, you will

4/18/24, 11:38 AM Assignment Information 1/3 IT 200 Project Two The IT Professional Guidelines and Rubric Competency In this project, you will demonstrate your mastery of the following competency: Articulate the roles and functions of the information technology professional Scenario Whether you are just beginning your career in information technology

### Lab Assignment #9 Confirmatory Factor Analysis using AMOS Goal of Exercise:  The goal of this exercise is to introduce how to operationalize the CFA

Lab Assignment #9 Confirmatory Factor Analysis using AMOS Goal of Exercise:  The goal of this exercise is to introduce how to operationalize the CFA using AMOS. The exercise allows students to learn how to check if the measurement model has acceptable levels of goodness-of-fit and evidence of construct validity.

### Lab – Configure IPv6 Addresses on Network Devices Lab – Configure IPv6 Addresses on Network Devices Topology Addressing

Lab – Configure IPv6 Addresses on Network Devices Lab – Configure IPv6 Addresses on Network Devices Topology Addressing Table Device Interface IPv6 Address Prefix Length Default Gateway R1 G0/0/0 2001:db8:acad:a::1 64 N/A R1 G0/0/1 2001:db8:acad:1::1 64 N/A S1 VLAN 1 2001:db8:acad:1::b 64 N/A PC-A NIC 2001:db8:acad:1::3 64 fe80::1 PC-B NIC

### Assignment 5 Due Saturday 11:59 pm (Week 12) Part 1 (40 points) This dataset contains State-by-state data on COVID-19 vaccinations in the United

Assignment 5 Due Saturday 11:59 pm (Week 12) Part 1 (40 points) This dataset contains State-by-state data on COVID-19 vaccinations in the United States from 1/2/2021 to 8/2/2021. You will be required to answer the following questions by timeseries analysis. * For vaccines that require multiple doses, each individual dose

,, I will upload more information about it to know better about the material Hi all, the instructions for the final project are attached. You are allowed to finish the project within 2 days at most. you can choose and tell me which option is easy and fast you

### file attached Read “Case 14.3: AI at Airbnb” and write an essay that answers the following questions: 1. How has Airbnb’s

file attached Read “Case 14.3: AI at Airbnb” and write an essay that answers the following questions: 1. How has Airbnb’s business model transformed the travel industry? 2. How does Airbnb use sentiment analysis to improve its services? 3. How does text mining help Airbnb gain insights from guest reviews?

### Prepare First, download and install CrypTool. If using a Windows® PC, install CrypTool 1.  If using a MAC PC, install JCrypTool. Note: In order for

Prepare First, download and install CrypTool. If using a Windows® PC, install CrypTool 1.  If using a MAC PC, install JCrypTool. Note: In order for the CrypTool program to function, you must first OPEN a text file. Only then will items on the toolbar become enabled. Additional information for this

### Why is an update/patch process crucial for any organization to have and follow?  Discuss some issues that may arise when patching and updating

Why is an update/patch process crucial for any organization to have and follow?  Discuss some issues that may arise when patching and updating machines.

Tasks may not be submitted as cloud links, such as links to Google Docs, Google Slides, OneDrive, etc., unless specified in the task requirements. All other submissions must be file types that are uploaded and submitted as attachments (e.g., .docx, .pdf, .ppt). A.  Address ethical issues for cybersecurity by

### The Cybersecurity Analyst’s Toolbox (Required/Graded) Discussion Topic During job interviews, employers often ask if you are

The Cybersecurity Analyst’s Toolbox (Required/Graded) Discussion Topic During job interviews, employers often ask if you are familiar with cybersecurity software. For this reason, it is a good idea to become familiar with commonly used software, including capabilities and limitations. These software products are the tools for conducting your day-to-day duties.

### Explain the differences between desktop and laptop architecture.  What features are specific to laptops and laptop displays? Describe the evolution of

Explain the differences between desktop and laptop architecture.  What features are specific to laptops and laptop displays? Describe the evolution of laptops into other mobile devices.

### I’m working on a WebApp platform React project. I have a small requiement that needs to be done. Enabling file upload option for a text field. I have

I’m working on a WebApp platform React project. I have a small requiement that needs to be done. Enabling file upload option for a text field. I have added a screenshot to understand the requirement better.