Question: This problem involves the OJ data set which is part of the ISLR package. (a) Create a training set containing a random sample of 800

This problem involves the OJ data set which is part of the ISLR package.

  1. (a) Create a training set containing a random sample of 800 observations, and a test

    set containing the remaining observations. Make sure to use set.seed(1).

  2. (b) (Please make sure to use set.seed(1) once again prior to each tune() operation, for parts (c) (d) as well.) Use tune() function to find the optimal support vector classifier with respect to cost value, using Purchase as the response and the other variables as predictors. Consider the following grid

of values for cost: 0.01, 0.05, 0.1, 0.5, 1, 10. Provide code and report both the training error and test error of the optimal selected model.

2

(c) Repeat part (b) using an SVM with a polynomial kernel with degree = 3.

  1. (d) Repeat part (b) using an SVM with a radial kernel with default gamma value

    (gamma = 2).

  2. (e) Which approach gave best results in terms of training error? Test error?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!