Question: Problem 4. This problem involves the OJ data set which is part of the ISLR package. To get this data use the following >install.packages( ISLR)

Problem 4. This problem involves the OJ data set which is part of the ISLR package. To get this data use the following >install.packages( "ISLR") > library(ISLR) > data(OJ) 4 HOMEWORK 2 DUE DATE: THURSDAY, FEBRUARY 22 AT 11:59 PM > View(OJ) (a) Create a training set containing a random sample of 800 observations, and a test set containing the remaining observations (b) Use the rpart(0 function with information purity measure function and fit a tree to the training data, with Purchase as the response and the other variables except for Buy as predictors. Use the summary0 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? (c) Pick one of the terminal nodes, and interpret the information displayed. (d) Create a plot of the tree. (e) Predict the response on the test data, and produce a summary of error rates for each class and compare the test labels to the predicted test labels. What is the test error rate? Problem 4. This problem involves the OJ data set which is part of the ISLR package. To get this data use the following >install.packages( "ISLR") > library(ISLR) > data(OJ) 4 HOMEWORK 2 DUE DATE: THURSDAY, FEBRUARY 22 AT 11:59 PM > View(OJ) (a) Create a training set containing a random sample of 800 observations, and a test set containing the remaining observations (b) Use the rpart(0 function with information purity measure function and fit a tree to the training data, with Purchase as the response and the other variables except for Buy as predictors. Use the summary0 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? (c) Pick one of the terminal nodes, and interpret the information displayed. (d) Create a plot of the tree. (e) Predict the response on the test data, and produce a summary of error rates for each class and compare the test labels to the predicted test labels. What is the test error rate
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
