Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Use theOJ (Orange Juice)data set for this question, which is part of theISLRpackage. Make sure to use R or R-studio for this question. You

1. Use theOJ (Orange Juice)data set for this question, which is part of theISLRpackage. Make sure to use R or R-studio for this question. You can find the data in ISLR package online. This data is also in the below link. Besides answers and steps, PLEASE also prepare the R file for R script (you can add screenshot of R script. Thanks!)

  1. (a)Creating a training set containing a random sample of 800 observations, and a test set containing the remaining observations.
  2. (b)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, and describe the results obtained. What is the training error rate? How many terminal nodes does the tree have?
  3. (c)Creating a plot of the tree, and interpret the results.
  4. (d)Predict the response on the test data, and produce a confusion matrix comparing the test labels to the predicted test labels. What is the test error rate?
  5. (e)Creating a pruned tree with four terminal nodes.
  6. (f)Compare the test error rates between the pruned and unpruned trees. Which is higher?

https://www.dropbox.com/scl/fi/bgil1agj5j05tkm0ywrkq/Orange-Juice-Data.docx?dl=0&rlkey=aplgmpuqztgaw8qurkvma3vke

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Engineering Mathematics

Authors: ERWIN KREYSZIG

9th Edition

0471488852, 978-0471488859

More Books

Students also viewed these Mathematics questions