5. We have seen that we can ft an SVM with a non-linear kernel in order

to perform classifcation using a non-linear decision boundary. We will

now see that we can also obtain a non-linear decision boundary by

performing logistic regression using non-linear transformations of the

features.

5a) Generate a data set with n = 500 and p = 2, such that the observations belong

to two classes with a quadratic decision boundary

between them. For instance, you can do this as follows:

set.seed(1)

 x1 <- runif(500) - 0.5
 x2 <- runif(500) - 0.5
 y <- 1 * (x1^2 - x2^2 > 0)
 
y = as.factor(y)
q5_df = data.frame(x1,x2,y)

5b)Plot the observations, colored according to their class labels.

Your plot should display X1 on the x-axis, and X2 on the yaxis.

ggplot(q5_df, aes(x=x1, y =x2, col = y)) +
  geom_point() +
  theme_minimal()

5c)Fit a logistic regression model to the data, using X1 and X2 as predictors.

logit = glm(y~x1+x2, data = q5_df, family = 'binomial')
logit
## 
## Call:  glm(formula = y ~ x1 + x2, family = "binomial", data = q5_df)
## 
## Coefficients:
## (Intercept)           x1           x2  
##   -0.087260     0.196199    -0.002854  
## 
## Degrees of Freedom: 499 Total (i.e. Null);  497 Residual
## Null Deviance:       692.2 
## Residual Deviance: 691.8     AIC: 697.8

5d) Apply this model to the training data in order to obtain a predicted

class label for each training observation. Plot the observations, colored

according to the predicted class labels. The decision boundary should be linear.

logit_pred = predict(logit, data.frame(x1,x2))
plot(x1,x2,col = ifelse(logit_pred > 0,'red','blue')) 

q5_df$logit_lin = ifelse(logit_pred > 0,1,0)
sum(q5_df$y == q5_df$logit_lin) / nrow(q5_df)
## [1] 0.57

5e) Now ft a logistic regression model to the data using non-linear

functions of X1 and X2 as predictors (e.g. X2 1 , X1×X2, log(X2),and so forth).

logit_non_linear = glm(y ~ log(x1) + log(x2), data = q5_df, family = 'binomial')
## Warning in log(x1): NaNs produced
## Warning in log(x2): NaNs produced
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
logit_non_linear
## 
## Call:  glm(formula = y ~ log(x1) + log(x2), family = "binomial", data = q5_df)
## 
## Coefficients:
## (Intercept)      log(x1)      log(x2)  
##      -44.49       497.86      -528.98  
## 
## Degrees of Freedom: 120 Total (i.e. Null);  118 Residual
##   (379 observations deleted due to missingness)
## Null Deviance:       167.7 
## Residual Deviance: 1.895e-07     AIC: 6

5f) Apply this model to the training data in order to obtain a predicted

class label for each training observation. Plot the observations, colored

according to the predicted class labels. The decision boundary should be

obviously non-linear. If it is not, then repeat (a)-(e) until you come up with

an example in which the predicted class labels are obviously non-linear.

non_linear_pred = predict(logit_non_linear, data.frame(x1,x2))
## Warning in log(x1): NaNs produced
## Warning in log(x2): NaNs produced
plot(x1,x2, col = ifelse(non_linear_pred>0,'red','blue'))

Looks like using log(x) did not work, going to try x^2

logit_non_linear = glm(y ~ I(x1**2) + I(x2**2), data = q5_df, family = 'binomial')
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
non_linear_pred = predict(logit_non_linear, data.frame(x1,x2))
plot(x1,x2, col = ifelse(non_linear_pred>0,'red','blue'))

No longer has a linear boundary and was able to converge.

q5_df$glm_nonlin = ifelse(non_linear_pred>0,1,0)
sum(q5_df$y == q5_df$glm_nonlin) / nrow(q5_df)
## [1] 1

5g) Fit a support vector classifer to the data with X1 and X2 as predictors.

Obtain a class prediction for each training observation. Plot the

observations, colored according to the predicted class labels.

set.seed(1)
linear_svm = svm(y~x1 + x2, data = q5_df, kernel = 'linear')
linear_pred = predict(linear_svm, q5_df)
plot(x1,x2,col = ifelse(linear_pred!=0,'red','blue')) 

linear_tune <- tune(svm, y~x1+x2, data = q5_df, kernel = "linear", ranges = list(
cost = c(0.1, 1, 10, 100, 1000),
gamma = c(0.5, 1, 2, 3, 4)))
linear_svm = linear_tune$best.model
linear_pred = predict(linear_svm, q5_df)
plot(x1,x2,col = ifelse(linear_pred!=0,'red','blue')) 

q5_df$svm_lin = linear_pred
sum(q5_df$y == q5_df$svm_lin) / nrow(q5_df)
## [1] 0.522

After trying to tune this model, I was getting an error regarding reaching max iterations. When the model finally ran, it still gave the same previous graph where there is only predicted 0’s. This suggests the data may be class imbalance, noisy data, or the data may not be linearly separable.

5h) Fit a SVM using a non-linear kernel to the data. Obtain a class

prediction for each training observation. Plot the observations,

colored according to the predicted class labels.

set.seed(1)
#radial_svm = svm(y~I(x1**2) + I(x2**2), data = q5_df, kernel = 'radial')

radial_out <- tune(svm, y ~ x1 + x2, data = q5_df, kernel = "radial", ranges = list(
cost = c(0.1, 1, 10, 100, 1000), gamma = c(0.5, 1, 2, 3, 4)))
radial_svm = radial_out$best.model
radial_pred = predict(radial_svm, q5_df)
plot(x1,x2,col = ifelse(radial_pred!=0,'red','blue')) 

q5_df$svm_nonlin = radial_pred
sum(q5_df$y == q5_df$svm_nonlin) / nrow(q5_df)
## [1] 1

5i) Comment on your results.

After running the logistic regressions and SVMs, it seems that the best models produced were the Non-Linear SVM & Logistic Regression.This is based on the accuracy scores produced which both equal 1. The logistic regression took more effort to produce since I began with using log(x) but when I switched to x^2, it gave the best results. The linear models gave accuracy scores slightly better than chance, but were only able to predict 0’s. This means that our data was probably not linearly separable which would be true since it looks quadratic. It seems that doing an SVM is a more time efficient method to testing different non-linear models compared to logistic regression, especially because you could just make a function to run multiple SVMs, change out the kernels and some hyper-parameters, then use the model that produced the best results.

7. In this problem, you will use support vector approaches in order to

predict whether a given car gets high or low gas mileage based on the

Auto data set

7a) Create a binary variable that takes on a 1 for cars with gas

mileage above the median, and a 0 for cars with gas mileage

below the median.

auto = ISLR2::Auto
mpg_binary = rep(0, length(auto$mpg))
mpg_binary[auto$mpg > median(auto$mpg)] = 1
auto = data.frame(auto, mpg_binary)
auto$mpg_binary = as.factor(auto$mpg_binary)

auto = auto %>% 
  dplyr::select(-c(name,mpg))
summary(auto)
##    cylinders      displacement     horsepower        weight      acceleration  
##  Min.   :3.000   Min.   : 68.0   Min.   : 46.0   Min.   :1613   Min.   : 8.00  
##  1st Qu.:4.000   1st Qu.:105.0   1st Qu.: 75.0   1st Qu.:2225   1st Qu.:13.78  
##  Median :4.000   Median :151.0   Median : 93.5   Median :2804   Median :15.50  
##  Mean   :5.472   Mean   :194.4   Mean   :104.5   Mean   :2978   Mean   :15.54  
##  3rd Qu.:8.000   3rd Qu.:275.8   3rd Qu.:126.0   3rd Qu.:3615   3rd Qu.:17.02  
##  Max.   :8.000   Max.   :455.0   Max.   :230.0   Max.   :5140   Max.   :24.80  
##       year           origin      mpg_binary
##  Min.   :70.00   Min.   :1.000   0:196     
##  1st Qu.:73.00   1st Qu.:1.000   1:196     
##  Median :76.00   Median :1.000             
##  Mean   :75.98   Mean   :1.577             
##  3rd Qu.:79.00   3rd Qu.:2.000             
##  Max.   :82.00   Max.   :3.000

7b) Fit a support vector classifer to the data with various values of cost,

in order to predict whether a car gets high or low gas mileage. Report the

cross-validation errors associated with different values of this parameter.

Comment on your results. Note you will need to fit the classifier without the gas

mileage variable to produce sensible results.

set.seed(1)
costs = seq(0.1,10,0.1)

linear_svm_tune = tune(svm, mpg_binary~., data = auto, kernel = 'linear',
                         scale = T, ranges = list(cost = costs))
summary(linear_svm_tune)
## 
## Parameter tuning of 'svm':
## 
## - sampling method: 10-fold cross validation 
## 
## - best parameters:
##  cost
##   0.5
## 
## - best performance: 0.08429487 
## 
## - Detailed performance results:
##     cost      error dispersion
## 1    0.1 0.09185897 0.04393409
## 2    0.2 0.08673077 0.04040897
## 3    0.3 0.08929487 0.03674971
## 4    0.4 0.08929487 0.03674971
## 5    0.5 0.08429487 0.04211652
## 6    0.6 0.08429487 0.03229996
## 7    0.7 0.08429487 0.03229996
## 8    0.8 0.08435897 0.03662670
## 9    0.9 0.08435897 0.03662670
## 10   1.0 0.08435897 0.03662670
## 11   1.1 0.08435897 0.03662670
## 12   1.2 0.08435897 0.03662670
## 13   1.3 0.08435897 0.03662670
## 14   1.4 0.08435897 0.03662670
## 15   1.5 0.08435897 0.03662670
## 16   1.6 0.08435897 0.03662670
## 17   1.7 0.08435897 0.03662670
## 18   1.8 0.08435897 0.03662670
## 19   1.9 0.08435897 0.03662670
## 20   2.0 0.08435897 0.03662670
## 21   2.1 0.08435897 0.03662670
## 22   2.2 0.08435897 0.03662670
## 23   2.3 0.08692308 0.03694444
## 24   2.4 0.08948718 0.03898410
## 25   2.5 0.08948718 0.03898410
## 26   2.6 0.08948718 0.03898410
## 27   2.7 0.08948718 0.03898410
## 28   2.8 0.08948718 0.03898410
## 29   2.9 0.08948718 0.03898410
## 30   3.0 0.08948718 0.03898410
## 31   3.1 0.08948718 0.03898410
## 32   3.2 0.08948718 0.03898410
## 33   3.3 0.08948718 0.03898410
## 34   3.4 0.08948718 0.03898410
## 35   3.5 0.08948718 0.03898410
## 36   3.6 0.08948718 0.03898410
## 37   3.7 0.08948718 0.03898410
## 38   3.8 0.08948718 0.03898410
## 39   3.9 0.08948718 0.03898410
## 40   4.0 0.08948718 0.03898410
## 41   4.1 0.08948718 0.03898410
## 42   4.2 0.08948718 0.03898410
## 43   4.3 0.08948718 0.03898410
## 44   4.4 0.08948718 0.03898410
## 45   4.5 0.08948718 0.03898410
## 46   4.6 0.08948718 0.03898410
## 47   4.7 0.08948718 0.03898410
## 48   4.8 0.08948718 0.03898410
## 49   4.9 0.08948718 0.03898410
## 50   5.0 0.08948718 0.03898410
## 51   5.1 0.08948718 0.03898410
## 52   5.2 0.08948718 0.03898410
## 53   5.3 0.08948718 0.03898410
## 54   5.4 0.08948718 0.03898410
## 55   5.5 0.08948718 0.03898410
## 56   5.6 0.08948718 0.03898410
## 57   5.7 0.08948718 0.03898410
## 58   5.8 0.08948718 0.03898410
## 59   5.9 0.08948718 0.03898410
## 60   6.0 0.08948718 0.03898410
## 61   6.1 0.08948718 0.03898410
## 62   6.2 0.08948718 0.03898410
## 63   6.3 0.08948718 0.03898410
## 64   6.4 0.08948718 0.03898410
## 65   6.5 0.08948718 0.03898410
## 66   6.6 0.08948718 0.03898410
## 67   6.7 0.08948718 0.03898410
## 68   6.8 0.08948718 0.03898410
## 69   6.9 0.08948718 0.03898410
## 70   7.0 0.08948718 0.03898410
## 71   7.1 0.08948718 0.03898410
## 72   7.2 0.08948718 0.03898410
## 73   7.3 0.08948718 0.03898410
## 74   7.4 0.08948718 0.03898410
## 75   7.5 0.08948718 0.03898410
## 76   7.6 0.08948718 0.03898410
## 77   7.7 0.08948718 0.03898410
## 78   7.8 0.08948718 0.03898410
## 79   7.9 0.08948718 0.03898410
## 80   8.0 0.08948718 0.03898410
## 81   8.1 0.08948718 0.03898410
## 82   8.2 0.08948718 0.03898410
## 83   8.3 0.08948718 0.03898410
## 84   8.4 0.08948718 0.03898410
## 85   8.5 0.08948718 0.03898410
## 86   8.6 0.08948718 0.03898410
## 87   8.7 0.08948718 0.03898410
## 88   8.8 0.08948718 0.03898410
## 89   8.9 0.08948718 0.03898410
## 90   9.0 0.08948718 0.03898410
## 91   9.1 0.08948718 0.03898410
## 92   9.2 0.08948718 0.03898410
## 93   9.3 0.08948718 0.03898410
## 94   9.4 0.08948718 0.03898410
## 95   9.5 0.08948718 0.03898410
## 96   9.6 0.08948718 0.03898410
## 97   9.7 0.08948718 0.03898410
## 98   9.8 0.08948718 0.03898410
## 99   9.9 0.08948718 0.03898410
## 100 10.0 0.08948718 0.03898410
plot(linear_svm_tune$performances[,c(1,2)], type = 'l')

Best performance is 0.08429487 which occurs at costs 0.5 and 0.7. So at a cost between (0.5,0.7) we would see the lowest error rate / highest accuracy in this specific SVM model.

7c) Now repeat (b), this time using SVMs with radial and polynomial basis

kernels, with different values of gamma and degree and cost. Comment on your results.

cl <- makeCluster(detectCores())
registerDoParallel(cl)

set.seed(1)
gammas = seq(0.1,3,0.1)
costs = seq(0.1,3,0.1)
ctrl = tune.control(cross = 5)
#radial_svm_tune = tune(svm, mpg_binary~., data = auto, kernel = 'radial',
#                         scale = T, ranges = list(cost = costs, gamma = gammas))
radial_svm_tune <- tune(svm, mpg_binary ~ ., data = auto, 
                        scale = TRUE, 
                        ranges = list(cost = costs, gamma = gammas),
                        method = 'radial',
                        tunecontrol = ctrl)
summary(radial_svm_tune)
## 
## Parameter tuning of 'svm':
## 
## - sampling method: 5-fold cross validation 
## 
## - best parameters:
##  cost gamma
##   0.9   1.3
## 
## - best performance: 0.06897111 
## 
## - Detailed performance results:
##     cost gamma      error dispersion
## 1    0.1   0.1 0.08935411 0.03862716
## 2    0.2   0.1 0.08935411 0.03862716
## 3    0.3   0.1 0.08935411 0.03862716
## 4    0.4   0.1 0.08935411 0.03862716
## 5    0.5   0.1 0.08679000 0.03333947
## 6    0.6   0.1 0.08679000 0.03333947
## 7    0.7   0.1 0.08935411 0.03410758
## 8    0.8   0.1 0.08935411 0.03410758
## 9    0.9   0.1 0.08935411 0.03410758
## 10   1.0   0.1 0.08935411 0.03410758
## 11   1.1   0.1 0.09188575 0.03332466
## 12   1.2   0.1 0.08935411 0.03410758
## 13   1.3   0.1 0.08935411 0.03410758
## 14   1.4   0.1 0.08935411 0.03410758
## 15   1.5   0.1 0.08935411 0.03410758
## 16   1.6   0.1 0.08935411 0.03410758
## 17   1.7   0.1 0.08935411 0.03410758
## 18   1.8   0.1 0.08935411 0.03410758
## 19   1.9   0.1 0.08935411 0.03410758
## 20   2.0   0.1 0.08935411 0.03410758
## 21   2.1   0.1 0.08682246 0.03578006
## 22   2.2   0.1 0.08682246 0.03578006
## 23   2.3   0.1 0.08938656 0.03294333
## 24   2.4   0.1 0.08682246 0.03215066
## 25   2.5   0.1 0.08682246 0.03215066
## 26   2.6   0.1 0.08682246 0.03215066
## 27   2.7   0.1 0.08682246 0.03215066
## 28   2.8   0.1 0.08682246 0.03215066
## 29   2.9   0.1 0.08682246 0.03215066
## 30   3.0   0.1 0.08682246 0.03215066
## 31   0.1   0.2 0.08935411 0.03862716
## 32   0.2   0.2 0.08935411 0.03862716
## 33   0.3   0.2 0.08935411 0.03862716
## 34   0.4   0.2 0.08935411 0.03862716
## 35   0.5   0.2 0.08679000 0.03333947
## 36   0.6   0.2 0.08679000 0.03333947
## 37   0.7   0.2 0.08682246 0.03578006
## 38   0.8   0.2 0.08682246 0.03578006
## 39   0.9   0.2 0.08682246 0.03578006
## 40   1.0   0.2 0.08938656 0.03294333
## 41   1.1   0.2 0.09191821 0.03085690
## 42   1.2   0.2 0.09191821 0.03085690
## 43   1.3   0.2 0.08938656 0.03294333
## 44   1.4   0.2 0.08682246 0.02805559
## 45   1.5   0.2 0.08425836 0.02681570
## 46   1.6   0.2 0.08682246 0.03215066
## 47   1.7   0.2 0.08679000 0.03205106
## 48   1.8   0.2 0.08679000 0.03205106
## 49   1.9   0.2 0.08935411 0.03024419
## 50   2.0   0.2 0.08935411 0.03024419
## 51   2.1   0.2 0.08682246 0.03084610
## 52   2.2   0.2 0.08682246 0.03084610
## 53   2.3   0.2 0.08682246 0.03084610
## 54   2.4   0.2 0.08682246 0.03084610
## 55   2.5   0.2 0.09195067 0.04216500
## 56   2.6   0.2 0.09195067 0.04216500
## 57   2.7   0.2 0.08938656 0.04367025
## 58   2.8   0.2 0.09191821 0.04211859
## 59   2.9   0.2 0.09191821 0.04211859
## 60   3.0   0.2 0.09191821 0.04211859
## 61   0.1   0.3 0.08679000 0.03901838
## 62   0.2   0.3 0.08935411 0.03862716
## 63   0.3   0.3 0.08935411 0.03862716
## 64   0.4   0.3 0.08679000 0.03333947
## 65   0.5   0.3 0.08935411 0.03410758
## 66   0.6   0.3 0.08938656 0.03294333
## 67   0.7   0.3 0.08938656 0.03294333
## 68   0.8   0.3 0.08425836 0.02681570
## 69   0.9   0.3 0.08425836 0.02681570
## 70   1.0   0.3 0.08682246 0.03215066
## 71   1.1   0.3 0.08425836 0.03236993
## 72   1.2   0.3 0.08679000 0.03205106
## 73   1.3   0.3 0.08429081 0.03365205
## 74   1.4   0.3 0.08172671 0.03482187
## 75   1.5   0.3 0.08429081 0.04031820
## 76   1.6   0.3 0.08685492 0.04587263
## 77   1.7   0.3 0.08938656 0.04367025
## 78   1.8   0.3 0.08938656 0.04367025
## 79   1.9   0.3 0.08938656 0.04367025
## 80   2.0   0.3 0.08682246 0.03800761
## 81   2.1   0.3 0.08682246 0.03800761
## 82   2.2   0.3 0.08682246 0.03800761
## 83   2.3   0.3 0.08682246 0.03800761
## 84   2.4   0.3 0.08172671 0.04031803
## 85   2.5   0.3 0.08172671 0.04031803
## 86   2.6   0.3 0.08425836 0.03925442
## 87   2.7   0.3 0.08425836 0.03925442
## 88   2.8   0.3 0.08425836 0.03925442
## 89   2.9   0.3 0.08422590 0.04023129
## 90   3.0   0.3 0.08422590 0.04023129
## 91   0.1   0.4 0.08679000 0.03901838
## 92   0.2   0.4 0.08679000 0.03901838
## 93   0.3   0.4 0.08679000 0.03333947
## 94   0.4   0.4 0.08169426 0.03478347
## 95   0.5   0.4 0.08425836 0.02681570
## 96   0.6   0.4 0.08425836 0.02681570
## 97   0.7   0.4 0.08682246 0.03215066
## 98   0.8   0.4 0.08425836 0.03236993
## 99   0.9   0.4 0.08425836 0.03236993
## 100  1.0   0.4 0.08169426 0.03358135
## 101  1.1   0.4 0.08425836 0.03925442
## 102  1.2   0.4 0.08172671 0.04129963
## 103  1.3   0.4 0.08172671 0.04031803
## 104  1.4   0.4 0.08429081 0.04605129
## 105  1.5   0.4 0.08429081 0.04605129
## 106  1.6   0.4 0.08172671 0.04031803
## 107  1.7   0.4 0.08172671 0.04031803
## 108  1.8   0.4 0.08172671 0.04031803
## 109  1.9   0.4 0.08425836 0.03925442
## 110  2.0   0.4 0.08169426 0.04126725
## 111  2.1   0.4 0.08169426 0.04126725
## 112  2.2   0.4 0.08169426 0.04126725
## 113  2.3   0.4 0.07656605 0.03015716
## 114  2.4   0.4 0.07909770 0.02928279
## 115  2.5   0.4 0.07909770 0.02928279
## 116  2.6   0.4 0.07909770 0.02928279
## 117  2.7   0.4 0.07653359 0.03265874
## 118  2.8   0.4 0.07653359 0.03265874
## 119  2.9   0.4 0.07143784 0.03465162
## 120  3.0   0.4 0.07143784 0.03465162
## 121  0.1   0.5 0.08679000 0.03901838
## 122  0.2   0.5 0.08679000 0.03901838
## 123  0.3   0.5 0.08169426 0.03478347
## 124  0.4   0.5 0.08425836 0.02681570
## 125  0.5   0.5 0.08425836 0.02681570
## 126  0.6   0.5 0.08682246 0.03215066
## 127  0.7   0.5 0.08169426 0.03358135
## 128  0.8   0.5 0.08422590 0.03351705
## 129  0.9   0.5 0.08172671 0.04031803
## 130  1.0   0.5 0.08172671 0.04031803
## 131  1.1   0.5 0.08425836 0.03925442
## 132  1.2   0.5 0.08425836 0.03925442
## 133  1.3   0.5 0.08682246 0.04494283
## 134  1.4   0.5 0.08425836 0.03925442
## 135  1.5   0.5 0.08169426 0.03358135
## 136  1.6   0.5 0.08422590 0.03229981
## 137  1.7   0.5 0.08166180 0.02668426
## 138  1.8   0.5 0.07913015 0.02793296
## 139  1.9   0.5 0.07913015 0.02793296
## 140  2.0   0.5 0.07400195 0.03197220
## 141  2.1   0.5 0.07400195 0.03197220
## 142  2.2   0.5 0.07147030 0.03227913
## 143  2.3   0.5 0.07400195 0.03197220
## 144  2.4   0.5 0.07400195 0.03197220
## 145  2.5   0.5 0.07400195 0.03197220
## 146  2.6   0.5 0.07400195 0.03197220
## 147  2.7   0.5 0.07400195 0.03197220
## 148  2.8   0.5 0.07400195 0.03197220
## 149  2.9   0.5 0.07400195 0.03197220
## 150  3.0   0.5 0.07656605 0.03015716
## 151  0.1   0.6 0.08679000 0.03901838
## 152  0.2   0.6 0.08935411 0.03862716
## 153  0.3   0.6 0.08169426 0.02968431
## 154  0.4   0.6 0.08425836 0.02681570
## 155  0.5   0.6 0.08425836 0.03236993
## 156  0.6   0.6 0.08169426 0.03358135
## 157  0.7   0.6 0.07916261 0.03458487
## 158  0.8   0.6 0.08172671 0.04031803
## 159  0.9   0.6 0.08172671 0.04031803
## 160  1.0   0.6 0.08425836 0.03925442
## 161  1.1   0.6 0.08425836 0.03925442
## 162  1.2   0.6 0.08682246 0.04494283
## 163  1.3   0.6 0.08429081 0.04691307
## 164  1.4   0.6 0.08172671 0.04129963
## 165  1.5   0.6 0.07913015 0.02793296
## 166  1.6   0.6 0.07913015 0.02793296
## 167  1.7   0.6 0.07403440 0.03074741
## 168  1.8   0.6 0.07403440 0.03074741
## 169  1.9   0.6 0.07403440 0.03074741
## 170  2.0   0.6 0.07656605 0.03015716
## 171  2.1   0.6 0.07400195 0.03197220
## 172  2.2   0.6 0.07400195 0.03197220
## 173  2.3   0.6 0.07400195 0.03197220
## 174  2.4   0.6 0.07400195 0.03197220
## 175  2.5   0.6 0.07400195 0.03197220
## 176  2.6   0.6 0.07400195 0.03197220
## 177  2.7   0.6 0.07656605 0.03015716
## 178  2.8   0.6 0.07656605 0.03015716
## 179  2.9   0.6 0.07656605 0.03015716
## 180  3.0   0.6 0.07656605 0.03015716
## 181  0.1   0.7 0.09188575 0.03793763
## 182  0.2   0.7 0.08679000 0.03333947
## 183  0.3   0.7 0.08425836 0.02681570
## 184  0.4   0.7 0.08425836 0.03236993
## 185  0.5   0.7 0.08169426 0.03358135
## 186  0.6   0.7 0.07916261 0.03458487
## 187  0.7   0.7 0.08172671 0.04031803
## 188  0.8   0.7 0.08172671 0.04031803
## 189  0.9   0.7 0.08172671 0.04031803
## 190  1.0   0.7 0.08172671 0.04129963
## 191  1.1   0.7 0.08172671 0.04129963
## 192  1.2   0.7 0.08172671 0.04129963
## 193  1.3   0.7 0.07916261 0.03572434
## 194  1.4   0.7 0.07150276 0.03233334
## 195  1.5   0.7 0.07403440 0.03074741
## 196  1.6   0.7 0.07403440 0.03074741
## 197  1.7   0.7 0.07403440 0.03074741
## 198  1.8   0.7 0.07656605 0.03015716
## 199  1.9   0.7 0.07656605 0.03015716
## 200  2.0   0.7 0.07656605 0.03015716
## 201  2.1   0.7 0.07656605 0.03015716
## 202  2.2   0.7 0.07656605 0.03015716
## 203  2.3   0.7 0.07656605 0.03015716
## 204  2.4   0.7 0.07656605 0.03015716
## 205  2.5   0.7 0.07656605 0.03015716
## 206  2.6   0.7 0.07913015 0.02936721
## 207  2.7   0.7 0.07913015 0.02936721
## 208  2.8   0.7 0.07913015 0.02936721
## 209  2.9   0.7 0.07913015 0.02936721
## 210  3.0   0.7 0.07656605 0.03015716
## 211  0.1   0.8 0.09441740 0.03701955
## 212  0.2   0.8 0.08932165 0.03278650
## 213  0.3   0.8 0.08425836 0.02681570
## 214  0.4   0.8 0.08425836 0.03236993
## 215  0.5   0.8 0.07916261 0.03458487
## 216  0.6   0.8 0.07916261 0.03458487
## 217  0.7   0.8 0.08172671 0.04031803
## 218  0.8   0.8 0.07919507 0.04212210
## 219  0.9   0.8 0.07919507 0.04212210
## 220  1.0   0.8 0.07916261 0.03572434
## 221  1.1   0.8 0.08172671 0.04129963
## 222  1.2   0.8 0.07406686 0.03797097
## 223  1.3   0.8 0.07150276 0.03233334
## 224  1.4   0.8 0.07150276 0.03233334
## 225  1.5   0.8 0.07403440 0.03202372
## 226  1.6   0.8 0.07656605 0.03015716
## 227  1.7   0.8 0.07656605 0.03015716
## 228  1.8   0.8 0.07656605 0.03015716
## 229  1.9   0.8 0.07656605 0.03015716
## 230  2.0   0.8 0.07656605 0.03015716
## 231  2.1   0.8 0.07656605 0.03015716
## 232  2.2   0.8 0.07656605 0.03015716
## 233  2.3   0.8 0.07656605 0.03015716
## 234  2.4   0.8 0.07656605 0.03015716
## 235  2.5   0.8 0.07913015 0.02936721
## 236  2.6   0.8 0.08166180 0.02818213
## 237  2.7   0.8 0.08166180 0.02818213
## 238  2.8   0.8 0.08166180 0.02818213
## 239  2.9   0.8 0.08166180 0.02818213
## 240  3.0   0.8 0.08166180 0.02818213
## 241  0.1   0.9 0.09444985 0.03481173
## 242  0.2   0.9 0.08675755 0.02786381
## 243  0.3   0.9 0.08169426 0.02677299
## 244  0.4   0.9 0.08172671 0.03365185
## 245  0.5   0.9 0.07916261 0.03458487
## 246  0.6   0.9 0.08172671 0.04031803
## 247  0.7   0.9 0.07919507 0.04212210
## 248  0.8   0.9 0.07663096 0.03645012
## 249  0.9   0.9 0.07663096 0.03645012
## 250  1.0   0.9 0.07916261 0.03572434
## 251  1.1   0.9 0.07663096 0.04363360
## 252  1.2   0.9 0.07150276 0.03233334
## 253  1.3   0.9 0.07403440 0.03202372
## 254  1.4   0.9 0.07403440 0.03202372
## 255  1.5   0.9 0.07403440 0.03202372
## 256  1.6   0.9 0.07403440 0.03202372
## 257  1.7   0.9 0.07403440 0.03202372
## 258  1.8   0.9 0.07403440 0.03202372
## 259  1.9   0.9 0.07403440 0.03202372
## 260  2.0   0.9 0.07403440 0.03202372
## 261  2.1   0.9 0.07656605 0.03015716
## 262  2.2   0.9 0.07656605 0.03015716
## 263  2.3   0.9 0.07656605 0.03015716
## 264  2.4   0.9 0.08166180 0.02818213
## 265  2.5   0.9 0.08166180 0.02818213
## 266  2.6   0.9 0.08166180 0.02818213
## 267  2.7   0.9 0.08166180 0.02818213
## 268  2.8   0.9 0.08166180 0.02818213
## 269  2.9   0.9 0.08166180 0.02818213
## 270  3.0   0.9 0.08166180 0.02818213
## 271  0.1   1.0 0.09698150 0.03356801
## 272  0.2   1.0 0.08675755 0.02786381
## 273  0.3   1.0 0.08679000 0.03205106
## 274  0.4   1.0 0.08172671 0.03365185
## 275  0.5   1.0 0.07916261 0.03458487
## 276  0.6   1.0 0.08172671 0.04031803
## 277  0.7   1.0 0.07663096 0.03645012
## 278  0.8   1.0 0.07409932 0.03801430
## 279  0.9   1.0 0.07663096 0.03645012
## 280  1.0   1.0 0.07406686 0.03797097
## 281  1.1   1.0 0.07659851 0.03749187
## 282  1.2   1.0 0.07403440 0.03202372
## 283  1.3   1.0 0.07403440 0.03202372
## 284  1.4   1.0 0.07403440 0.03202372
## 285  1.5   1.0 0.07403440 0.03202372
## 286  1.6   1.0 0.07403440 0.03202372
## 287  1.7   1.0 0.07656605 0.03015716
## 288  1.8   1.0 0.07656605 0.03015716
## 289  1.9   1.0 0.07656605 0.03015716
## 290  2.0   1.0 0.07656605 0.03015716
## 291  2.1   1.0 0.07656605 0.03015716
## 292  2.2   1.0 0.07656605 0.03015716
## 293  2.3   1.0 0.07913015 0.02936721
## 294  2.4   1.0 0.07913015 0.02936721
## 295  2.5   1.0 0.07913015 0.02936721
## 296  2.6   1.0 0.07913015 0.02936721
## 297  2.7   1.0 0.07913015 0.02936721
## 298  2.8   1.0 0.07913015 0.02936721
## 299  2.9   1.0 0.07913015 0.02936721
## 300  3.0   1.0 0.08166180 0.02818213
## 301  0.1   1.1 0.10204479 0.02864029
## 302  0.2   1.1 0.08675755 0.02786381
## 303  0.3   1.1 0.08425836 0.03236993
## 304  0.4   1.1 0.08172671 0.03482187
## 305  0.5   1.1 0.07663096 0.03645012
## 306  0.6   1.1 0.07666342 0.04366892
## 307  0.7   1.1 0.07409932 0.03801430
## 308  0.8   1.1 0.07663096 0.03645012
## 309  0.9   1.1 0.07153522 0.03926884
## 310  1.0   1.1 0.07403440 0.03202372
## 311  1.1   1.1 0.07659851 0.03749187
## 312  1.2   1.1 0.07403440 0.03202372
## 313  1.3   1.1 0.07403440 0.03202372
## 314  1.4   1.1 0.07403440 0.03202372
## 315  1.5   1.1 0.07656605 0.03015716
## 316  1.6   1.1 0.07656605 0.03015716
## 317  1.7   1.1 0.07656605 0.03015716
## 318  1.8   1.1 0.07656605 0.03015716
## 319  1.9   1.1 0.07656605 0.03015716
## 320  2.0   1.1 0.07656605 0.03015716
## 321  2.1   1.1 0.07656605 0.03015716
## 322  2.2   1.1 0.07913015 0.02936721
## 323  2.3   1.1 0.07913015 0.02936721
## 324  2.4   1.1 0.07913015 0.02936721
## 325  2.5   1.1 0.07913015 0.02936721
## 326  2.6   1.1 0.07913015 0.02936721
## 327  2.7   1.1 0.07913015 0.02936721
## 328  2.8   1.1 0.07913015 0.02936721
## 329  2.9   1.1 0.07913015 0.02936721
## 330  3.0   1.1 0.07913015 0.02936721
## 331  0.1   1.2 0.10963973 0.02455324
## 332  0.2   1.2 0.08932165 0.02412174
## 333  0.3   1.2 0.08172671 0.02972930
## 334  0.4   1.2 0.08172671 0.03482187
## 335  0.5   1.2 0.07663096 0.03645012
## 336  0.6   1.2 0.07666342 0.04366892
## 337  0.7   1.2 0.07663096 0.03645012
## 338  0.8   1.2 0.07409932 0.03801430
## 339  0.9   1.2 0.07153522 0.03926884
## 340  1.0   1.2 0.07406686 0.03797097
## 341  1.1   1.2 0.07659851 0.03749187
## 342  1.2   1.2 0.07659851 0.03749187
## 343  1.3   1.2 0.07656605 0.03015716
## 344  1.4   1.2 0.07656605 0.03015716
## 345  1.5   1.2 0.07656605 0.03015716
## 346  1.6   1.2 0.07656605 0.03015716
## 347  1.7   1.2 0.07656605 0.03015716
## 348  1.8   1.2 0.07913015 0.03568399
## 349  1.9   1.2 0.07913015 0.03568399
## 350  2.0   1.2 0.07656605 0.03015716
## 351  2.1   1.2 0.07913015 0.02936721
## 352  2.2   1.2 0.07913015 0.02936721
## 353  2.3   1.2 0.07913015 0.02936721
## 354  2.4   1.2 0.07659851 0.03024254
## 355  2.5   1.2 0.07659851 0.03024254
## 356  2.6   1.2 0.07659851 0.03024254
## 357  2.7   1.2 0.07659851 0.03024254
## 358  2.8   1.2 0.07659851 0.03024254
## 359  2.9   1.2 0.07659851 0.03024254
## 360  3.0   1.2 0.07659851 0.03024254
## 361  0.1   1.3 0.11476793 0.02537008
## 362  0.2   1.3 0.09185329 0.02300586
## 363  0.3   1.3 0.08425836 0.02681570
## 364  0.4   1.3 0.08172671 0.03482187
## 365  0.5   1.3 0.07916261 0.03572434
## 366  0.6   1.3 0.07663096 0.03645012
## 367  0.7   1.3 0.07409932 0.03801430
## 368  0.8   1.3 0.07153522 0.03926884
## 369  0.9   1.3 0.06897111 0.03360749
## 370  1.0   1.3 0.07406686 0.03797097
## 371  1.1   1.3 0.07659851 0.03640776
## 372  1.2   1.3 0.07659851 0.03640776
## 373  1.3   1.3 0.07659851 0.03640776
## 374  1.4   1.3 0.07659851 0.03640776
## 375  1.5   1.3 0.07403440 0.03074741
## 376  1.6   1.3 0.07659851 0.03640776
## 377  1.7   1.3 0.07659851 0.03640776
## 378  1.8   1.3 0.07659851 0.03640776
## 379  1.9   1.3 0.07659851 0.03640776
## 380  2.0   1.3 0.07916261 0.03575326
## 381  2.1   1.3 0.07659851 0.03024254
## 382  2.2   1.3 0.07659851 0.03024254
## 383  2.3   1.3 0.07659851 0.03024254
## 384  2.4   1.3 0.07659851 0.03024254
## 385  2.5   1.3 0.07659851 0.03024254
## 386  2.6   1.3 0.07659851 0.03024254
## 387  2.7   1.3 0.07659851 0.03024254
## 388  2.8   1.3 0.07659851 0.03024254
## 389  2.9   1.3 0.07656605 0.02409820
## 390  3.0   1.3 0.07656605 0.02409820
## 391  0.1   1.4 0.13012009 0.01892844
## 392  0.2   1.4 0.09188575 0.02128545
## 393  0.3   1.4 0.08425836 0.02681570
## 394  0.4   1.4 0.08169426 0.02677299
## 395  0.5   1.4 0.08172671 0.03365185
## 396  0.6   1.4 0.07666342 0.03760157
## 397  0.7   1.4 0.07409932 0.03801430
## 398  0.8   1.4 0.07153522 0.03926884
## 399  0.9   1.4 0.07150276 0.03233334
## 400  1.0   1.4 0.07659851 0.03640776
## 401  1.1   1.4 0.07659851 0.03640776
## 402  1.2   1.4 0.07659851 0.03640776
## 403  1.3   1.4 0.07659851 0.03640776
## 404  1.4   1.4 0.07659851 0.03640776
## 405  1.5   1.4 0.07659851 0.03640776
## 406  1.6   1.4 0.07659851 0.03640776
## 407  1.7   1.4 0.07659851 0.03640776
## 408  1.8   1.4 0.07659851 0.03640776
## 409  1.9   1.4 0.07916261 0.03575326
## 410  2.0   1.4 0.07916261 0.03575326
## 411  2.1   1.4 0.07659851 0.03024254
## 412  2.2   1.4 0.07659851 0.03024254
## 413  2.3   1.4 0.07659851 0.03024254
## 414  2.4   1.4 0.07659851 0.03024254
## 415  2.5   1.4 0.07659851 0.03024254
## 416  2.6   1.4 0.07403440 0.02483289
## 417  2.7   1.4 0.07656605 0.02409820
## 418  2.8   1.4 0.07656605 0.02409820
## 419  2.9   1.4 0.07656605 0.02409820
## 420  3.0   1.4 0.07656605 0.02409820
## 421  0.1   1.5 0.14037650 0.02426120
## 422  0.2   1.5 0.09694904 0.01948150
## 423  0.3   1.5 0.08679000 0.02486813
## 424  0.4   1.5 0.08675755 0.02473917
## 425  0.5   1.5 0.08425836 0.03236993
## 426  0.6   1.5 0.08172671 0.03482187
## 427  0.7   1.5 0.07409932 0.03801430
## 428  0.8   1.5 0.07409932 0.03801430
## 429  0.9   1.5 0.07403440 0.03074741
## 430  1.0   1.5 0.07659851 0.03640776
## 431  1.1   1.5 0.07659851 0.03640776
## 432  1.2   1.5 0.07659851 0.03640776
## 433  1.3   1.5 0.07659851 0.03640776
## 434  1.4   1.5 0.07659851 0.03640776
## 435  1.5   1.5 0.07659851 0.03640776
## 436  1.6   1.5 0.07659851 0.03640776
## 437  1.7   1.5 0.07659851 0.03640776
## 438  1.8   1.5 0.07916261 0.03575326
## 439  1.9   1.5 0.07916261 0.03575326
## 440  2.0   1.5 0.07916261 0.03575326
## 441  2.1   1.5 0.07916261 0.02802140
## 442  2.2   1.5 0.07916261 0.02802140
## 443  2.3   1.5 0.07659851 0.02244320
## 444  2.4   1.5 0.07913015 0.02124898
## 445  2.5   1.5 0.07913015 0.02124898
## 446  2.6   1.5 0.07913015 0.02124898
## 447  2.7   1.5 0.07913015 0.02124898
## 448  2.8   1.5 0.07913015 0.02124898
## 449  2.9   1.5 0.07913015 0.02124898
## 450  3.0   1.5 0.08169426 0.01969928
## 451  0.1   1.6 0.15316456 0.04064443
## 452  0.2   1.6 0.09698150 0.01746378
## 453  0.3   1.6 0.08932165 0.02412174
## 454  0.4   1.6 0.08675755 0.02473917
## 455  0.5   1.6 0.08169426 0.02677299
## 456  0.6   1.6 0.08679000 0.03077588
## 457  0.7   1.6 0.07663096 0.03645012
## 458  0.8   1.6 0.07406686 0.03080094
## 459  0.9   1.6 0.07659851 0.02885183
## 460  1.0   1.6 0.07916261 0.03458487
## 461  1.1   1.6 0.07916261 0.03458487
## 462  1.2   1.6 0.07916261 0.03458487
## 463  1.3   1.6 0.07916261 0.03458487
## 464  1.4   1.6 0.07916261 0.03458487
## 465  1.5   1.6 0.07916261 0.03458487
## 466  1.6   1.6 0.07916261 0.03458487
## 467  1.7   1.6 0.08172671 0.03365185
## 468  1.8   1.6 0.08172671 0.03365185
## 469  1.9   1.6 0.08172671 0.03365185
## 470  2.0   1.6 0.08172671 0.03365185
## 471  2.1   1.6 0.07916261 0.02802140
## 472  2.2   1.6 0.07659851 0.02244320
## 473  2.3   1.6 0.07913015 0.02124898
## 474  2.4   1.6 0.07913015 0.02124898
## 475  2.5   1.6 0.07913015 0.02124898
## 476  2.6   1.6 0.07913015 0.02124898
## 477  2.7   1.6 0.07913015 0.02124898
## 478  2.8   1.6 0.07913015 0.02124898
## 479  2.9   1.6 0.08169426 0.01969928
## 480  3.0   1.6 0.08169426 0.01969928
## 481  0.1   1.7 0.16079195 0.03240287
## 482  0.2   1.7 0.09698150 0.01746378
## 483  0.3   1.7 0.09188575 0.02128545
## 484  0.4   1.7 0.08932165 0.02235342
## 485  0.5   1.7 0.08169426 0.02677299
## 486  0.6   1.7 0.08679000 0.03077588
## 487  0.7   1.7 0.08169426 0.03358135
## 488  0.8   1.7 0.07406686 0.03080094
## 489  0.9   1.7 0.07659851 0.02885183
## 490  1.0   1.7 0.07916261 0.03458487
## 491  1.1   1.7 0.07916261 0.03458487
## 492  1.2   1.7 0.07916261 0.03458487
## 493  1.3   1.7 0.07916261 0.03458487
## 494  1.4   1.7 0.07916261 0.03458487
## 495  1.5   1.7 0.07916261 0.03458487
## 496  1.6   1.7 0.08172671 0.03365185
## 497  1.7   1.7 0.08172671 0.03365185
## 498  1.8   1.7 0.08172671 0.03365185
## 499  1.9   1.7 0.07916261 0.02802140
## 500  2.0   1.7 0.07916261 0.02802140
## 501  2.1   1.7 0.08169426 0.02677299
## 502  2.2   1.7 0.07913015 0.02124898
## 503  2.3   1.7 0.07913015 0.02124898
## 504  2.4   1.7 0.08169426 0.02677299
## 505  2.5   1.7 0.08169426 0.02677299
## 506  2.6   1.7 0.08675755 0.02778952
## 507  2.7   1.7 0.08675755 0.02778952
## 508  2.8   1.7 0.08932165 0.02568864
## 509  2.9   1.7 0.08932165 0.02568864
## 510  3.0   1.7 0.09444985 0.02514841
## 511  0.1   1.8 0.16588770 0.03036191
## 512  0.2   1.8 0.09951315 0.01913669
## 513  0.3   1.8 0.09441740 0.01960239
## 514  0.4   1.8 0.08932165 0.02235342
## 515  0.5   1.8 0.08169426 0.02677299
## 516  0.6   1.8 0.08169426 0.02677299
## 517  0.7   1.8 0.08675755 0.03198344
## 518  0.8   1.8 0.08166180 0.02668426
## 519  0.9   1.8 0.08675755 0.03198344
## 520  1.0   1.8 0.07916261 0.03458487
## 521  1.1   1.8 0.07916261 0.03458487
## 522  1.2   1.8 0.07916261 0.03458487
## 523  1.3   1.8 0.07916261 0.03458487
## 524  1.4   1.8 0.07916261 0.03458487
## 525  1.5   1.8 0.08172671 0.03365185
## 526  1.6   1.8 0.08172671 0.03365185
## 527  1.7   1.8 0.07916261 0.02802140
## 528  1.8   1.8 0.07916261 0.02802140
## 529  1.9   1.8 0.08169426 0.02677299
## 530  2.0   1.8 0.08675755 0.02778952
## 531  2.1   1.8 0.08675755 0.02778952
## 532  2.2   1.8 0.08675755 0.02778952
## 533  2.3   1.8 0.08675755 0.02778952
## 534  2.4   1.8 0.08675755 0.02778952
## 535  2.5   1.8 0.08675755 0.02778952
## 536  2.6   1.8 0.08675755 0.02778952
## 537  2.7   1.8 0.08932165 0.02568864
## 538  2.8   1.8 0.08932165 0.02568864
## 539  2.9   1.8 0.09188575 0.02476492
## 540  3.0   1.8 0.09444985 0.02514841
## 541  0.1   1.9 0.18883479 0.04675689
## 542  0.2   1.9 0.10710808 0.02115564
## 543  0.3   1.9 0.09698150 0.01746378
## 544  0.4   1.9 0.08679000 0.02315688
## 545  0.5   1.9 0.08425836 0.02523685
## 546  0.6   1.9 0.07913015 0.02793296
## 547  0.7   1.9 0.08675755 0.03198344
## 548  0.8   1.9 0.08416099 0.02132569
## 549  0.9   1.9 0.08675755 0.03198344
## 550  1.0   1.9 0.08675755 0.03198344
## 551  1.1   1.9 0.08675755 0.03198344
## 552  1.2   1.9 0.08675755 0.03198344
## 553  1.3   1.9 0.08675755 0.03198344
## 554  1.4   1.9 0.08932165 0.03017597
## 555  1.5   1.9 0.08932165 0.03017597
## 556  1.6   1.9 0.08675755 0.02473917
## 557  1.7   1.9 0.08675755 0.02473917
## 558  1.8   1.9 0.08675755 0.02473917
## 559  1.9   1.9 0.08928919 0.02560824
## 560  2.0   1.9 0.08928919 0.02560824
## 561  2.1   1.9 0.08928919 0.02560824
## 562  2.2   1.9 0.08928919 0.02560824
## 563  2.3   1.9 0.08928919 0.02560824
## 564  2.4   1.9 0.08928919 0.02560824
## 565  2.5   1.9 0.08928919 0.02560824
## 566  2.6   1.9 0.09185329 0.02296089
## 567  2.7   1.9 0.09185329 0.02296089
## 568  2.8   1.9 0.09185329 0.02296089
## 569  2.9   1.9 0.09694904 0.01948150
## 570  3.0   1.9 0.09698150 0.02161670
## 571  0.1   2.0 0.19905875 0.05511882
## 572  0.2   2.0 0.10967218 0.02124396
## 573  0.3   2.0 0.09441740 0.01960239
## 574  0.4   2.0 0.08935411 0.02249143
## 575  0.5   2.0 0.08425836 0.02523685
## 576  0.6   2.0 0.08166180 0.02668426
## 577  0.7   2.0 0.08419344 0.02660716
## 578  0.8   2.0 0.08416099 0.02132569
## 579  0.9   2.0 0.08672509 0.02622613
## 580  1.0   2.0 0.08675755 0.03198344
## 581  1.1   2.0 0.08675755 0.03198344
## 582  1.2   2.0 0.08675755 0.03198344
## 583  1.3   2.0 0.08675755 0.03198344
## 584  1.4   2.0 0.08932165 0.03017597
## 585  1.5   2.0 0.08675755 0.02473917
## 586  1.6   2.0 0.08675755 0.02473917
## 587  1.7   2.0 0.08675755 0.02473917
## 588  1.8   2.0 0.08928919 0.02560824
## 589  1.9   2.0 0.08928919 0.02560824
## 590  2.0   2.0 0.08928919 0.02560824
## 591  2.1   2.0 0.08928919 0.02560824
## 592  2.2   2.0 0.08928919 0.02560824
## 593  2.3   2.0 0.09182084 0.02456418
## 594  2.4   2.0 0.09182084 0.02456418
## 595  2.5   2.0 0.09438494 0.02141473
## 596  2.6   2.0 0.09438494 0.02141473
## 597  2.7   2.0 0.09438494 0.02141473
## 598  2.8   2.0 0.09441740 0.02154922
## 599  2.9   2.0 0.09698150 0.02161670
## 600  3.0   2.0 0.09698150 0.02161670
## 601  0.1   2.1 0.21181435 0.05804602
## 602  0.2   2.1 0.11480039 0.01276472
## 603  0.3   2.1 0.09698150 0.01746378
## 604  0.4   2.1 0.09188575 0.02128545
## 605  0.5   2.1 0.08425836 0.02523685
## 606  0.6   2.1 0.08422590 0.02514684
## 607  0.7   2.1 0.08162934 0.02141701
## 608  0.8   2.1 0.08416099 0.02132569
## 609  0.9   2.1 0.08672509 0.02622613
## 610  1.0   2.1 0.08672509 0.02622613
## 611  1.1   2.1 0.08928919 0.03140988
## 612  1.2   2.1 0.08928919 0.03140988
## 613  1.3   2.1 0.09185329 0.02929165
## 614  1.4   2.1 0.08928919 0.02399305
## 615  1.5   2.1 0.08928919 0.02399305
## 616  1.6   2.1 0.08928919 0.02399305
## 617  1.7   2.1 0.09182084 0.02456418
## 618  1.8   2.1 0.09182084 0.02456418
## 619  1.9   2.1 0.09182084 0.02456418
## 620  2.0   2.1 0.09182084 0.02456418
## 621  2.1   2.1 0.09182084 0.02456418
## 622  2.2   2.1 0.09182084 0.02456418
## 623  2.3   2.1 0.09182084 0.02456418
## 624  2.4   2.1 0.09182084 0.02456418
## 625  2.5   2.1 0.09438494 0.02141473
## 626  2.6   2.1 0.09185329 0.02296089
## 627  2.7   2.1 0.09441740 0.02154922
## 628  2.8   2.1 0.09441740 0.02154922
## 629  2.9   2.1 0.09698150 0.02161670
## 630  3.0   2.1 0.09441740 0.02507458
## 631  0.1   2.2 0.23982473 0.07284439
## 632  0.2   2.2 0.12499189 0.02267882
## 633  0.3   2.2 0.09441740 0.01960239
## 634  0.4   2.2 0.09188575 0.02128545
## 635  0.5   2.2 0.08425836 0.02523685
## 636  0.6   2.2 0.08422590 0.02514684
## 637  0.7   2.2 0.08162934 0.02141701
## 638  0.8   2.2 0.08159688 0.01695602
## 639  0.9   2.2 0.08672509 0.02622613
## 640  1.0   2.2 0.08672509 0.02622613
## 641  1.1   2.2 0.08672509 0.02622613
## 642  1.2   2.2 0.09185329 0.02929165
## 643  1.3   2.2 0.08928919 0.02399305
## 644  1.4   2.2 0.08928919 0.02399305
## 645  1.5   2.2 0.08928919 0.02399305
## 646  1.6   2.2 0.09182084 0.02456418
## 647  1.7   2.2 0.09182084 0.02456418
## 648  1.8   2.2 0.09182084 0.02456418
## 649  1.9   2.2 0.09182084 0.02456418
## 650  2.0   2.2 0.09182084 0.02456418
## 651  2.1   2.2 0.09182084 0.02456418
## 652  2.2   2.2 0.09182084 0.02456418
## 653  2.3   2.2 0.09182084 0.02456418
## 654  2.4   2.2 0.09185329 0.02296089
## 655  2.5   2.2 0.09185329 0.02296089
## 656  2.6   2.2 0.09185329 0.02296089
## 657  2.7   2.2 0.09441740 0.02154922
## 658  2.8   2.2 0.09441740 0.02507458
## 659  2.9   2.2 0.09441740 0.02507458
## 660  3.0   2.2 0.09441740 0.02507458
## 661  0.1   2.3 0.27559234 0.08655256
## 662  0.2   2.3 0.12755599 0.02549476
## 663  0.3   2.3 0.09951315 0.02107750
## 664  0.4   2.3 0.08935411 0.02249143
## 665  0.5   2.3 0.08682246 0.02495498
## 666  0.6   2.3 0.08422590 0.02514684
## 667  0.7   2.3 0.08419344 0.01947332
## 668  0.8   2.3 0.08159688 0.01695602
## 669  0.9   2.3 0.08672509 0.02622613
## 670  1.0   2.3 0.08672509 0.02622613
## 671  1.1   2.3 0.08672509 0.02622613
## 672  1.2   2.3 0.08928919 0.02399305
## 673  1.3   2.3 0.08928919 0.02399305
## 674  1.4   2.3 0.08928919 0.02399305
## 675  1.5   2.3 0.09182084 0.02456418
## 676  1.6   2.3 0.09182084 0.02456418
## 677  1.7   2.3 0.09182084 0.02456418
## 678  1.8   2.3 0.09182084 0.02456418
## 679  1.9   2.3 0.09182084 0.02456418
## 680  2.0   2.3 0.09182084 0.02456418
## 681  2.1   2.3 0.09182084 0.02456418
## 682  2.2   2.3 0.09182084 0.02456418
## 683  2.3   2.3 0.08928919 0.02560824
## 684  2.4   2.3 0.09185329 0.02296089
## 685  2.5   2.3 0.09185329 0.02296089
## 686  2.6   2.3 0.09441740 0.02154922
## 687  2.7   2.3 0.09185329 0.02468573
## 688  2.8   2.3 0.09441740 0.02507458
## 689  2.9   2.3 0.09441740 0.02507458
## 690  3.0   2.3 0.09698150 0.02963436
## 691  0.1   2.4 0.29604025 0.07971079
## 692  0.2   2.4 0.14031159 0.02549801
## 693  0.3   2.4 0.10207725 0.02035949
## 694  0.4   2.4 0.08935411 0.02249143
## 695  0.5   2.4 0.09188575 0.02128545
## 696  0.6   2.4 0.08422590 0.02514684
## 697  0.7   2.4 0.08419344 0.01947332
## 698  0.8   2.4 0.08159688 0.01695602
## 699  0.9   2.4 0.08672509 0.02622613
## 700  1.0   2.4 0.08672509 0.02622613
## 701  1.1   2.4 0.08928919 0.02399305
## 702  1.2   2.4 0.08928919 0.02399305
## 703  1.3   2.4 0.08928919 0.02399305
## 704  1.4   2.4 0.08928919 0.02399305
## 705  1.5   2.4 0.09182084 0.02456418
## 706  1.6   2.4 0.09182084 0.02456418
## 707  1.7   2.4 0.09182084 0.02456418
## 708  1.8   2.4 0.09182084 0.02456418
## 709  1.9   2.4 0.09182084 0.02456418
## 710  2.0   2.4 0.09182084 0.02456418
## 711  2.1   2.4 0.08928919 0.02560824
## 712  2.2   2.4 0.08928919 0.02560824
## 713  2.3   2.4 0.09185329 0.02296089
## 714  2.4   2.4 0.09185329 0.02296089
## 715  2.5   2.4 0.09441740 0.02154922
## 716  2.6   2.4 0.09185329 0.02468573
## 717  2.7   2.4 0.09441740 0.02507458
## 718  2.8   2.4 0.09441740 0.02507458
## 719  2.9   2.4 0.09698150 0.02963436
## 720  3.0   2.4 0.09698150 0.02963436
## 721  0.1   2.5 0.35215839 0.09407715
## 722  0.2   2.5 0.15306719 0.02009433
## 723  0.3   2.5 0.10207725 0.02035949
## 724  0.4   2.5 0.09191821 0.02142549
## 725  0.5   2.5 0.08932165 0.02412174
## 726  0.6   2.5 0.08679000 0.02486813
## 727  0.7   2.5 0.08419344 0.01947332
## 728  0.8   2.5 0.08416099 0.01443041
## 729  0.9   2.5 0.08416099 0.02132569
## 730  1.0   2.5 0.08672509 0.02622613
## 731  1.1   2.5 0.08928919 0.02399305
## 732  1.2   2.5 0.08928919 0.02399305
## 733  1.3   2.5 0.08928919 0.02399305
## 734  1.4   2.5 0.09182084 0.02456418
## 735  1.5   2.5 0.09182084 0.02456418
## 736  1.6   2.5 0.09182084 0.02456418
## 737  1.7   2.5 0.09182084 0.02456418
## 738  1.8   2.5 0.09182084 0.02456418
## 739  1.9   2.5 0.09182084 0.02456418
## 740  2.0   2.5 0.08928919 0.02560824
## 741  2.1   2.5 0.08928919 0.02560824
## 742  2.2   2.5 0.08928919 0.02560824
## 743  2.3   2.5 0.09185329 0.02296089
## 744  2.4   2.5 0.09441740 0.02154922
## 745  2.5   2.5 0.09185329 0.02468573
## 746  2.6   2.5 0.09185329 0.02468573
## 747  2.7   2.5 0.09441740 0.02507458
## 748  2.8   2.5 0.09698150 0.02963436
## 749  2.9   2.5 0.09698150 0.02963436
## 750  3.0   2.5 0.09698150 0.02963436
## 751  0.1   2.6 0.37007465 0.10483795
## 752  0.2   2.6 0.15306719 0.02383585
## 753  0.3   2.6 0.10464135 0.01919166
## 754  0.4   2.6 0.09191821 0.02142549
## 755  0.5   2.6 0.09188575 0.02484826
## 756  0.6   2.6 0.08935411 0.02588880
## 757  0.7   2.6 0.08675755 0.01911749
## 758  0.8   2.6 0.08672509 0.01395396
## 759  0.9   2.6 0.08416099 0.02132569
## 760  1.0   2.6 0.08928919 0.02399305
## 761  1.1   2.6 0.08928919 0.02399305
## 762  1.2   2.6 0.08928919 0.02399305
## 763  1.3   2.6 0.08928919 0.02399305
## 764  1.4   2.6 0.09182084 0.02456418
## 765  1.5   2.6 0.09182084 0.02456418
## 766  1.6   2.6 0.09182084 0.02456418
## 767  1.7   2.6 0.09182084 0.02456418
## 768  1.8   2.6 0.09182084 0.02456418
## 769  1.9   2.6 0.08928919 0.02560824
## 770  2.0   2.6 0.08928919 0.02560824
## 771  2.1   2.6 0.08928919 0.02560824
## 772  2.2   2.6 0.08928919 0.02560824
## 773  2.3   2.6 0.09441740 0.02154922
## 774  2.4   2.6 0.09185329 0.02468573
## 775  2.5   2.6 0.09185329 0.02468573
## 776  2.6   2.6 0.09441740 0.02507458
## 777  2.7   2.6 0.09441740 0.02507458
## 778  2.8   2.6 0.09698150 0.02963436
## 779  2.9   2.6 0.09698150 0.02963436
## 780  3.0   2.6 0.09954560 0.03454566
## 781  0.1   2.7 0.40334307 0.10396513
## 782  0.2   2.7 0.15303473 0.01986185
## 783  0.3   2.7 0.10720545 0.01969460
## 784  0.4   2.7 0.10207725 0.02035949
## 785  0.5   2.7 0.08932165 0.02412174
## 786  0.6   2.7 0.08935411 0.02588880
## 787  0.7   2.7 0.08928919 0.01814162
## 788  0.8   2.7 0.08672509 0.01395396
## 789  0.9   2.7 0.08928919 0.01814162
## 790  1.0   2.7 0.08928919 0.02399305
## 791  1.1   2.7 0.08928919 0.02399305
## 792  1.2   2.7 0.08928919 0.02399305
## 793  1.3   2.7 0.09182084 0.02456418
## 794  1.4   2.7 0.09182084 0.02456418
## 795  1.5   2.7 0.09182084 0.02456418
## 796  1.6   2.7 0.09182084 0.02456418
## 797  1.7   2.7 0.09182084 0.02456418
## 798  1.8   2.7 0.08928919 0.02560824
## 799  1.9   2.7 0.08928919 0.02560824
## 800  2.0   2.7 0.08928919 0.02560824
## 801  2.1   2.7 0.08928919 0.02560824
## 802  2.2   2.7 0.08928919 0.02560824
## 803  2.3   2.7 0.09185329 0.02468573
## 804  2.4   2.7 0.09185329 0.02468573
## 805  2.5   2.7 0.09185329 0.02468573
## 806  2.6   2.7 0.09441740 0.02507458
## 807  2.7   2.7 0.09698150 0.02963436
## 808  2.8   2.7 0.09698150 0.02963436
## 809  2.9   2.7 0.09954560 0.03454566
## 810  3.0   2.7 0.09954560 0.03454566
## 811  0.1   2.8 0.43644920 0.09333641
## 812  0.2   2.8 0.15813048 0.02452399
## 813  0.3   2.8 0.11230120 0.02305475
## 814  0.4   2.8 0.10207725 0.02035949
## 815  0.5   2.8 0.09444985 0.01974915
## 816  0.6   2.8 0.08935411 0.02588880
## 817  0.7   2.8 0.08932165 0.02043264
## 818  0.8   2.8 0.08672509 0.01395396
## 819  0.9   2.8 0.08928919 0.01814162
## 820  1.0   2.8 0.09185329 0.02300586
## 821  1.1   2.8 0.09185329 0.02300586
## 822  1.2   2.8 0.08928919 0.02399305
## 823  1.3   2.8 0.09182084 0.02456418
## 824  1.4   2.8 0.09182084 0.02456418
## 825  1.5   2.8 0.09182084 0.02456418
## 826  1.6   2.8 0.09182084 0.02456418
## 827  1.7   2.8 0.08928919 0.02560824
## 828  1.8   2.8 0.08928919 0.02560824
## 829  1.9   2.8 0.08928919 0.02560824
## 830  2.0   2.8 0.08928919 0.02560824
## 831  2.1   2.8 0.08928919 0.02560824
## 832  2.2   2.8 0.09441740 0.02154922
## 833  2.3   2.8 0.09185329 0.02468573
## 834  2.4   2.8 0.09185329 0.02468573
## 835  2.5   2.8 0.09185329 0.02468573
## 836  2.6   2.8 0.09698150 0.02963436
## 837  2.7   2.8 0.09698150 0.02963436
## 838  2.8   2.8 0.09954560 0.03454566
## 839  2.9   2.8 0.09698150 0.02963436
## 840  3.0   2.8 0.09698150 0.02963436
## 841  0.1   2.9 0.45173645 0.08651772
## 842  0.2   2.9 0.16069458 0.02624916
## 843  0.3   2.9 0.11483285 0.02557253
## 844  0.4   2.9 0.10207725 0.02035949
## 845  0.5   2.9 0.09444985 0.01974915
## 846  0.6   2.9 0.09444985 0.02173044
## 847  0.7   2.9 0.08932165 0.02043264
## 848  0.8   2.9 0.08672509 0.01395396
## 849  0.9   2.9 0.08928919 0.01814162
## 850  1.0   2.9 0.09185329 0.02300586
## 851  1.1   2.9 0.09185329 0.02300586
## 852  1.2   2.9 0.09438494 0.02325454
## 853  1.3   2.9 0.09438494 0.02325454
## 854  1.4   2.9 0.09438494 0.02325454
## 855  1.5   2.9 0.09182084 0.02456418
## 856  1.6   2.9 0.09182084 0.02456418
## 857  1.7   2.9 0.08928919 0.02560824
## 858  1.8   2.9 0.08928919 0.02560824
## 859  1.9   2.9 0.08928919 0.02560824
## 860  2.0   2.9 0.08928919 0.02560824
## 861  2.1   2.9 0.09185329 0.02296089
## 862  2.2   2.9 0.09185329 0.02468573
## 863  2.3   2.9 0.09185329 0.02468573
## 864  2.4   2.9 0.09185329 0.02468573
## 865  2.5   2.9 0.09441740 0.02507458
## 866  2.6   2.9 0.09698150 0.02963436
## 867  2.7   2.9 0.09698150 0.02963436
## 868  2.8   2.9 0.09698150 0.02963436
## 869  2.9   2.9 0.09698150 0.02963436
## 870  3.0   2.9 0.09698150 0.02963436
## 871  0.1   3.0 0.46449205 0.07859356
## 872  0.2   3.0 0.16832197 0.02871720
## 873  0.3   3.0 0.11992859 0.02328662
## 874  0.4   3.0 0.10464135 0.01919166
## 875  0.5   3.0 0.09444985 0.01974915
## 876  0.6   3.0 0.08932165 0.01590997
## 877  0.7   3.0 0.08932165 0.02043264
## 878  0.8   3.0 0.08672509 0.01395396
## 879  0.9   3.0 0.08928919 0.01814162
## 880  1.0   3.0 0.09185329 0.02300586
## 881  1.1   3.0 0.09185329 0.02300586
## 882  1.2   3.0 0.09438494 0.02325454
## 883  1.3   3.0 0.09438494 0.02325454
## 884  1.4   3.0 0.09182084 0.01889049
## 885  1.5   3.0 0.09438494 0.02325454
## 886  1.6   3.0 0.09185329 0.02468573
## 887  1.7   3.0 0.09185329 0.02468573
## 888  1.8   3.0 0.09185329 0.02468573
## 889  1.9   3.0 0.09185329 0.02468573
## 890  2.0   3.0 0.09185329 0.02296089
## 891  2.1   3.0 0.08928919 0.02560824
## 892  2.2   3.0 0.09185329 0.02468573
## 893  2.3   3.0 0.09185329 0.02468573
## 894  2.4   3.0 0.09185329 0.02468573
## 895  2.5   3.0 0.09441740 0.02507458
## 896  2.6   3.0 0.09698150 0.02963436
## 897  2.7   3.0 0.09698150 0.02963436
## 898  2.8   3.0 0.09698150 0.02963436
## 899  2.9   3.0 0.09698150 0.02963436
## 900  3.0   3.0 0.09698150 0.02963436
stopCluster(cl)

The model with the best performance uses a cost of 0.9 and a gamma of 1.3. This gives us an error rate of 0.06897111.

cl <- makeCluster(detectCores())
registerDoParallel(cl)
gammas = seq(0.1,1.5,0.1)
costs = seq(0.1,1.5,0.1)
degrees = 2 #seq(1,3,1) --- Changing because it is taking to long to run
ctrl = tune.control(cross = 5)
poly_svm_tune = tune(svm, mpg_binary~., data = auto, method = 'polynomial',
                         scale = T, ranges = list(cost = costs, gamma = gammas,
                                                  degree = degrees))
summary(poly_svm_tune)
## 
## Parameter tuning of 'svm':
## 
## - sampling method: 10-fold cross validation 
## 
## - best parameters:
##  cost gamma degree
##   1.1     1      2
## 
## - best performance: 0.07115385 
## 
## - Detailed performance results:
##     cost gamma degree      error dispersion
## 1    0.1   0.1      2 0.09160256 0.05496767
## 2    0.2   0.1      2 0.09160256 0.05496767
## 3    0.3   0.1      2 0.09160256 0.05496767
## 4    0.4   0.1      2 0.09160256 0.05496767
## 5    0.5   0.1      2 0.09160256 0.05496767
## 6    0.6   0.1      2 0.09160256 0.05496767
## 7    0.7   0.1      2 0.09160256 0.05496767
## 8    0.8   0.1      2 0.09160256 0.05496767
## 9    0.9   0.1      2 0.09160256 0.05496767
## 10   1.0   0.1      2 0.09160256 0.05496767
## 11   1.1   0.1      2 0.08903846 0.05759286
## 12   1.2   0.1      2 0.08903846 0.05759286
## 13   1.3   0.1      2 0.08903846 0.05759286
## 14   1.4   0.1      2 0.09160256 0.06004878
## 15   1.5   0.1      2 0.08903846 0.05759286
## 16   0.1   0.2      2 0.09160256 0.05496767
## 17   0.2   0.2      2 0.09160256 0.05496767
## 18   0.3   0.2      2 0.09160256 0.05496767
## 19   0.4   0.2      2 0.09160256 0.05496767
## 20   0.5   0.2      2 0.09160256 0.05496767
## 21   0.6   0.2      2 0.09160256 0.05496767
## 22   0.7   0.2      2 0.08903846 0.05759286
## 23   0.8   0.2      2 0.08903846 0.05759286
## 24   0.9   0.2      2 0.08647436 0.05489453
## 25   1.0   0.2      2 0.08903846 0.05759286
## 26   1.1   0.2      2 0.08647436 0.05749448
## 27   1.2   0.2      2 0.08647436 0.05749448
## 28   1.3   0.2      2 0.08647436 0.05749448
## 29   1.4   0.2      2 0.08647436 0.05620954
## 30   1.5   0.2      2 0.08647436 0.05216516
## 31   0.1   0.3      2 0.08903846 0.05759286
## 32   0.2   0.3      2 0.08903846 0.05759286
## 33   0.3   0.3      2 0.09160256 0.05496767
## 34   0.4   0.3      2 0.09160256 0.05496767
## 35   0.5   0.3      2 0.08903846 0.05759286
## 36   0.6   0.3      2 0.08903846 0.05759286
## 37   0.7   0.3      2 0.08391026 0.05465781
## 38   0.8   0.3      2 0.08391026 0.05465781
## 39   0.9   0.3      2 0.08134615 0.05691343
## 40   1.0   0.3      2 0.08134615 0.05818282
## 41   1.1   0.3      2 0.08391026 0.05465781
## 42   1.2   0.3      2 0.08391026 0.05465781
## 43   1.3   0.3      2 0.08647436 0.05875132
## 44   1.4   0.3      2 0.08647436 0.05875132
## 45   1.5   0.3      2 0.08647436 0.05875132
## 46   0.1   0.4      2 0.08647436 0.05749448
## 47   0.2   0.4      2 0.08903846 0.05759286
## 48   0.3   0.4      2 0.08903846 0.05759286
## 49   0.4   0.4      2 0.08903846 0.05759286
## 50   0.5   0.4      2 0.08391026 0.05465781
## 51   0.6   0.4      2 0.08641026 0.05725603
## 52   0.7   0.4      2 0.08391026 0.05976527
## 53   0.8   0.4      2 0.08134615 0.05818282
## 54   0.9   0.4      2 0.08647436 0.05620954
## 55   1.0   0.4      2 0.08641026 0.05725603
## 56   1.1   0.4      2 0.08641026 0.05725603
## 57   1.2   0.4      2 0.08128205 0.05536192
## 58   1.3   0.4      2 0.08128205 0.05536192
## 59   1.4   0.4      2 0.07871795 0.05745980
## 60   1.5   0.4      2 0.07871795 0.05745980
## 61   0.1   0.5      2 0.08647436 0.05749448
## 62   0.2   0.5      2 0.08647436 0.05749448
## 63   0.3   0.5      2 0.08647436 0.05749448
## 64   0.4   0.5      2 0.08134615 0.05561507
## 65   0.5   0.5      2 0.08128205 0.06160727
## 66   0.6   0.5      2 0.08134615 0.05818282
## 67   0.7   0.5      2 0.08134615 0.05818282
## 68   0.8   0.5      2 0.08384615 0.05573017
## 69   0.9   0.5      2 0.08384615 0.05573017
## 70   1.0   0.5      2 0.08128205 0.05536192
## 71   1.1   0.5      2 0.07871795 0.05745980
## 72   1.2   0.5      2 0.07871795 0.05745980
## 73   1.3   0.5      2 0.07871795 0.05745980
## 74   1.4   0.5      2 0.08128205 0.05402629
## 75   1.5   0.5      2 0.08128205 0.05402629
## 76   0.1   0.6      2 0.08647436 0.05749448
## 77   0.2   0.6      2 0.08647436 0.05749448
## 78   0.3   0.6      2 0.08391026 0.05853020
## 79   0.4   0.6      2 0.08384615 0.06425395
## 80   0.5   0.6      2 0.08134615 0.05818282
## 81   0.6   0.6      2 0.07621795 0.05580520
## 82   0.7   0.6      2 0.07871795 0.05871739
## 83   0.8   0.6      2 0.08128205 0.05536192
## 84   0.9   0.6      2 0.08128205 0.05536192
## 85   1.0   0.6      2 0.07871795 0.05745980
## 86   1.1   0.6      2 0.07871795 0.05745980
## 87   1.2   0.6      2 0.08128205 0.05402629
## 88   1.3   0.6      2 0.08128205 0.05402629
## 89   1.4   0.6      2 0.08128205 0.05402629
## 90   1.5   0.6      2 0.08384615 0.05164827
## 91   0.1   0.7      2 0.08903846 0.05631017
## 92   0.2   0.7      2 0.08647436 0.05749448
## 93   0.3   0.7      2 0.08134615 0.06183485
## 94   0.4   0.7      2 0.08384615 0.06425395
## 95   0.5   0.7      2 0.07621795 0.05580520
## 96   0.6   0.7      2 0.07871795 0.05871739
## 97   0.7   0.7      2 0.08128205 0.05536192
## 98   0.8   0.7      2 0.08128205 0.05536192
## 99   0.9   0.7      2 0.07871795 0.05745980
## 100  1.0   0.7      2 0.07871795 0.05745980
## 101  1.1   0.7      2 0.08128205 0.05402629
## 102  1.2   0.7      2 0.08384615 0.05304381
## 103  1.3   0.7      2 0.08128205 0.04980494
## 104  1.4   0.7      2 0.07871795 0.04924442
## 105  1.5   0.7      2 0.07621795 0.04573294
## 106  0.1   0.8      2 0.08910256 0.05901538
## 107  0.2   0.8      2 0.08647436 0.05749448
## 108  0.3   0.8      2 0.08134615 0.06183485
## 109  0.4   0.8      2 0.07615385 0.06057894
## 110  0.5   0.8      2 0.08128205 0.05794090
## 111  0.6   0.8      2 0.08384615 0.05440357
## 112  0.7   0.8      2 0.08128205 0.05402629
## 113  0.8   0.8      2 0.07871795 0.05617407
## 114  0.9   0.8      2 0.08128205 0.05666609
## 115  1.0   0.8      2 0.08384615 0.05304381
## 116  1.1   0.8      2 0.08384615 0.05304381
## 117  1.2   0.8      2 0.07365385 0.04795136
## 118  1.3   0.8      2 0.07365385 0.04795136
## 119  1.4   0.8      2 0.07621795 0.04573294
## 120  1.5   0.8      2 0.07878205 0.04489056
## 121  0.1   0.9      2 0.09166667 0.05898442
## 122  0.2   0.9      2 0.08141026 0.05709648
## 123  0.3   0.9      2 0.07878205 0.06018548
## 124  0.4   0.9      2 0.07871795 0.05871739
## 125  0.5   0.9      2 0.08128205 0.05794090
## 126  0.6   0.9      2 0.08384615 0.05440357
## 127  0.7   0.9      2 0.08128205 0.05402629
## 128  0.8   0.9      2 0.07871795 0.05617407
## 129  0.9   0.9      2 0.08384615 0.05304381
## 130  1.0   0.9      2 0.07621795 0.04730332
## 131  1.1   0.9      2 0.07365385 0.04795136
## 132  1.2   0.9      2 0.07365385 0.04795136
## 133  1.3   0.9      2 0.07371795 0.04504545
## 134  1.4   0.9      2 0.07371795 0.04504545
## 135  1.5   0.9      2 0.07628205 0.04596849
## 136  0.1   1.0      2 0.08653846 0.06135196
## 137  0.2   1.0      2 0.08141026 0.05709648
## 138  0.3   1.0      2 0.07365385 0.05763724
## 139  0.4   1.0      2 0.08128205 0.05794090
## 140  0.5   1.0      2 0.08384615 0.05440357
## 141  0.6   1.0      2 0.08384615 0.05440357
## 142  0.7   1.0      2 0.08384615 0.05440357
## 143  0.8   1.0      2 0.08128205 0.05402629
## 144  0.9   1.0      2 0.07621795 0.04730332
## 145  1.0   1.0      2 0.07365385 0.04795136
## 146  1.1   1.0      2 0.07115385 0.04556946
## 147  1.2   1.0      2 0.07371795 0.04504545
## 148  1.3   1.0      2 0.07371795 0.04504545
## 149  1.4   1.0      2 0.07628205 0.04596849
## 150  1.5   1.0      2 0.07628205 0.04596849
## 151  0.1   1.1      2 0.08653846 0.06135196
## 152  0.2   1.1      2 0.08910256 0.06377480
## 153  0.3   1.1      2 0.07371795 0.05524320
## 154  0.4   1.1      2 0.08128205 0.05794090
## 155  0.5   1.1      2 0.08384615 0.05440357
## 156  0.6   1.1      2 0.08384615 0.05440357
## 157  0.7   1.1      2 0.08384615 0.05440357
## 158  0.8   1.1      2 0.07878205 0.04803507
## 159  0.9   1.1      2 0.07365385 0.04640291
## 160  1.0   1.1      2 0.07115385 0.04556946
## 161  1.1   1.1      2 0.07371795 0.04504545
## 162  1.2   1.1      2 0.07371795 0.04504545
## 163  1.3   1.1      2 0.07628205 0.04596849
## 164  1.4   1.1      2 0.07628205 0.04596849
## 165  1.5   1.1      2 0.07628205 0.04596849
## 166  0.1   1.2      2 0.08653846 0.06135196
## 167  0.2   1.2      2 0.08910256 0.06377480
## 168  0.3   1.2      2 0.07371795 0.05524320
## 169  0.4   1.2      2 0.08134615 0.05428566
## 170  0.5   1.2      2 0.08384615 0.05440357
## 171  0.6   1.2      2 0.08384615 0.05440357
## 172  0.7   1.2      2 0.07878205 0.05239920
## 173  0.8   1.2      2 0.07621795 0.04410667
## 174  0.9   1.2      2 0.07115385 0.04224181
## 175  1.0   1.2      2 0.07115385 0.04556946
## 176  1.1   1.2      2 0.07371795 0.04504545
## 177  1.2   1.2      2 0.07371795 0.04504545
## 178  1.3   1.2      2 0.07628205 0.04596849
## 179  1.4   1.2      2 0.07628205 0.04596849
## 180  1.5   1.2      2 0.07628205 0.04596849
## 181  0.1   1.3      2 0.08653846 0.06135196
## 182  0.2   1.3      2 0.08397436 0.05993656
## 183  0.3   1.3      2 0.08141026 0.05311968
## 184  0.4   1.3      2 0.08391026 0.05465781
## 185  0.5   1.3      2 0.08134615 0.05152405
## 186  0.6   1.3      2 0.08128205 0.05536192
## 187  0.7   1.3      2 0.07621795 0.04882322
## 188  0.8   1.3      2 0.07371795 0.04167598
## 189  0.9   1.3      2 0.07115385 0.04224181
## 190  1.0   1.3      2 0.07371795 0.04167598
## 191  1.1   1.3      2 0.07628205 0.04267196
## 192  1.2   1.3      2 0.07628205 0.04596849
## 193  1.3   1.3      2 0.07628205 0.04596849
## 194  1.4   1.3      2 0.07628205 0.04596849
## 195  1.5   1.3      2 0.08141026 0.04065561
## 196  0.1   1.4      2 0.08653846 0.06135196
## 197  0.2   1.4      2 0.08397436 0.05993656
## 198  0.3   1.4      2 0.08141026 0.05311968
## 199  0.4   1.4      2 0.08897436 0.05468566
## 200  0.5   1.4      2 0.08897436 0.05468566
## 201  0.6   1.4      2 0.07628205 0.05051148
## 202  0.7   1.4      2 0.07621795 0.04882322
## 203  0.8   1.4      2 0.07371795 0.04167598
## 204  0.9   1.4      2 0.07371795 0.04167598
## 205  1.0   1.4      2 0.07371795 0.04167598
## 206  1.1   1.4      2 0.07628205 0.04267196
## 207  1.2   1.4      2 0.07884615 0.04347752
## 208  1.3   1.4      2 0.08141026 0.04065561
## 209  1.4   1.4      2 0.08141026 0.04065561
## 210  1.5   1.4      2 0.08141026 0.04065561
## 211  0.1   1.5      2 0.09166667 0.06374616
## 212  0.2   1.5      2 0.08653846 0.05766935
## 213  0.3   1.5      2 0.08397436 0.05484506
## 214  0.4   1.5      2 0.08897436 0.05468566
## 215  0.5   1.5      2 0.08641026 0.05590113
## 216  0.6   1.5      2 0.08141026 0.05029408
## 217  0.7   1.5      2 0.07628205 0.04267196
## 218  0.8   1.5      2 0.07371795 0.04167598
## 219  0.9   1.5      2 0.07371795 0.04167598
## 220  1.0   1.5      2 0.07371795 0.04167598
## 221  1.1   1.5      2 0.07371795 0.04167598
## 222  1.2   1.5      2 0.08141026 0.04065561
## 223  1.3   1.5      2 0.08141026 0.04065561
## 224  1.4   1.5      2 0.08141026 0.04065561
## 225  1.5   1.5      2 0.08141026 0.04065561
stopCluster(cl)

The polynomial best parameters are a cost of 1.1, gamma of 0.9, and a degree of 2, but this is also with my extremely reduced ranges due to the hours spent trying to run this code with seq(0.1,10,0.1) on all three parameters.

With the radial SVM we get an error rate of 0.0690 and with the polynomial SVM we get an error rate of 0.0637. This suggests that the polynomial model is slightly better

7d) Make some plots to back up your assertions in (b) and (c).

svm_best_rad = svm(mpg_binary~., data = auto, kernel = 'radial', scale = T,
           cost = 0.9 , gamma = 1.3)
plot(svm_best_rad, auto, weight ~ horsepower)

plot(svm_best_rad, auto, year ~ acceleration)

plot(svm_best_rad, auto, weight ~ displacement)

plot(svm_best_rad, auto, weight ~ acceleration)

svm_best_poly = svm(mpg_binary~., data = auto, kernel = 'polynomial', scale = T,
           cost = 1.1 , gamma = 0.9, degree = 2)
plot(svm_best_poly, auto, weight ~ horsepower)

plot(svm_best_poly, auto, year ~ acceleration)

plot(svm_best_poly, auto, weight ~ displacement)

plot(svm_best_poly, auto, weight ~ acceleration)

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

8a) Create a training set containing a random sample of 800 observations,

and a test set containing the remaining observations.

OJ = ISLR2::OJ
set.seed(1)
index = sample(1:nrow(OJ), 800)
OJ_train = OJ[index,]
OJ_test = OJ[-index,]

8b) Fit a support vector classifer to the training data using cost = 0.01,

with Purchase as the response and the other variables as predictors. Use the

summary() function to produce summary statistics, and describe the results obtained.

oj_linear = svm(Purchase ~., data = OJ_train, kernel = 'linear', cost = 0.01, scale = T)
summary(oj_linear)
## 
## Call:
## svm(formula = Purchase ~ ., data = OJ_train, kernel = "linear", cost = 0.01, 
##     scale = T)
## 
## 
## Parameters:
##    SVM-Type:  C-classification 
##  SVM-Kernel:  linear 
##        cost:  0.01 
## 
## Number of Support Vectors:  435
## 
##  ( 219 216 )
## 
## 
## Number of Classes:  2 
## 
## Levels: 
##  CH MM

Of our 800 observations, we have 435 support vectors to help classify if people will purchase Citrus Hill or Minute Maid with 219 Vectors for Citrus Hill and 216 for Minute Maid.

8c) What are the training and test error rates?

train_err = mean(predict(oj_linear, OJ_train) != OJ_train$Purchase)
test_err = mean(predict(oj_linear, OJ_test) != OJ_test$Purchase)
paste('Train Error: ' , train_err)
## [1] "Train Error:  0.175"
paste('Test Error: ', test_err)
## [1] "Test Error:  0.177777777777778"

We get a Train Error of 0.175 and a Test Error of 0.177.

8d) Use the tune() function to select an optimal cost. Consider values in the

range 0.01 to 10.

set.seed(1)
costs = seq(0.01, 10, 0.1)
ctrl = tune.control(cross = 5)
#oj_tune = tune(svm, Purchase~., data=OJ_train, 
#               ranges = list(cost = costs,tunecontrol = ctrl), method = 'linear')
library(doParallel)

# Set up parallel processing
cl <- makeCluster(detectCores())
registerDoParallel(cl)

# Perform hyperparameter tuning
oj_tune <- tune(svm, Purchase ~ ., data = OJ_train,
                ranges = list(cost = costs),
                tunecontrol = ctrl, method = 'linear')

# Stop cluster
stopCluster(cl)
summary(oj_tune)
## 
## Parameter tuning of 'svm':
## 
## - sampling method: 5-fold cross validation 
## 
## - best parameters:
##  cost
##  0.61
## 
## - best performance: 0.165 
## 
## - Detailed performance results:
##     cost   error  dispersion
## 1   0.01 0.39375 0.021194781
## 2   0.11 0.19000 0.009478594
## 3   0.21 0.17750 0.018540496
## 4   0.31 0.17625 0.022707378
## 5   0.41 0.17500 0.015934436
## 6   0.51 0.17125 0.018006075
## 7   0.61 0.16500 0.016886570
## 8   0.71 0.16625 0.016298006
## 9   0.81 0.16625 0.018006075
## 10  0.91 0.16500 0.016886570
## 11  1.01 0.16625 0.014388581
## 12  1.11 0.16625 0.016298006
## 13  1.21 0.16625 0.018540496
## 14  1.31 0.16875 0.015934436
## 15  1.41 0.17000 0.018957189
## 16  1.51 0.17125 0.018540496
## 17  1.61 0.17250 0.020539596
## 18  1.71 0.17125 0.020058508
## 19  1.81 0.17125 0.020058508
## 20  1.91 0.17250 0.018540496
## 21  2.01 0.17375 0.019465514
## 22  2.11 0.17375 0.019465514
## 23  2.21 0.17375 0.019465514
## 24  2.31 0.17250 0.018006075
## 25  2.41 0.17375 0.019465514
## 26  2.51 0.17625 0.016770510
## 27  2.61 0.17625 0.016770510
## 28  2.71 0.17750 0.014388581
## 29  2.81 0.17750 0.014388581
## 30  2.91 0.17625 0.013549677
## 31  3.01 0.17625 0.013549677
## 32  3.11 0.17625 0.013549677
## 33  3.21 0.17750 0.013693064
## 34  3.31 0.17875 0.013693064
## 35  3.41 0.17875 0.013693064
## 36  3.51 0.17875 0.013693064
## 37  3.61 0.17875 0.013693064
## 38  3.71 0.17875 0.013693064
## 39  3.81 0.17875 0.013693064
## 40  3.91 0.17875 0.013693064
## 41  4.01 0.17875 0.013693064
## 42  4.11 0.17875 0.013693064
## 43  4.21 0.18000 0.014252193
## 44  4.31 0.18125 0.011692679
## 45  4.41 0.18125 0.011692679
## 46  4.51 0.18000 0.012022115
## 47  4.61 0.18000 0.012022115
## 48  4.71 0.17875 0.010458250
## 49  4.81 0.17875 0.010458250
## 50  4.91 0.17875 0.010458250
## 51  5.01 0.18000 0.012022115
## 52  5.11 0.18000 0.012022115
## 53  5.21 0.17875 0.011353689
## 54  5.31 0.17875 0.011353689
## 55  5.41 0.17875 0.011353689
## 56  5.51 0.17875 0.011353689
## 57  5.61 0.17875 0.011353689
## 58  5.71 0.17875 0.011353689
## 59  5.81 0.17875 0.011353689
## 60  5.91 0.17875 0.011353689
## 61  6.01 0.17875 0.011353689
## 62  6.11 0.17875 0.011353689
## 63  6.21 0.17875 0.011353689
## 64  6.31 0.18125 0.012500000
## 65  6.41 0.18125 0.012500000
## 66  6.51 0.18125 0.012500000
## 67  6.61 0.18250 0.012022115
## 68  6.71 0.18250 0.012022115
## 69  6.81 0.18250 0.012022115
## 70  6.91 0.18250 0.012022115
## 71  7.01 0.18375 0.012960276
## 72  7.11 0.18375 0.012960276
## 73  7.21 0.18625 0.014921670
## 74  7.31 0.18625 0.014921670
## 75  7.41 0.18625 0.014921670
## 76  7.51 0.18625 0.014921670
## 77  7.61 0.18625 0.014921670
## 78  7.71 0.18625 0.014921670
## 79  7.81 0.18500 0.015687375
## 80  7.91 0.18500 0.015687375
## 81  8.01 0.18500 0.015687375
## 82  8.11 0.18500 0.015687375
## 83  8.21 0.18375 0.014388581
## 84  8.31 0.18375 0.014388581
## 85  8.41 0.18375 0.014388581
## 86  8.51 0.18375 0.014388581
## 87  8.61 0.18375 0.014388581
## 88  8.71 0.18375 0.014388581
## 89  8.81 0.18375 0.014388581
## 90  8.91 0.18375 0.014388581
## 91  9.01 0.18375 0.014388581
## 92  9.11 0.18250 0.013549677
## 93  9.21 0.18375 0.015051993
## 94  9.31 0.18375 0.015051993
## 95  9.41 0.18375 0.015051993
## 96  9.51 0.18375 0.015051993
## 97  9.61 0.18375 0.015051993
## 98  9.71 0.18375 0.015051993
## 99  9.81 0.18375 0.015051993
## 100 9.91 0.18375 0.015051993

We get an optimal cost of 0.61 with an error rate of 0.165. I did adjust the limits on cost because I have had the SVM running for a lot longer than expected.

8e) Compute the training and test error rates using this new value for cost.

train_err = mean(predict(oj_tune$best.model, OJ_train) != OJ_train$Purchase)
test_err = mean(predict(oj_tune$best.model, OJ_test) != OJ_test$Purchase)
paste('Train Error: ', train_err)
## [1] "Train Error:  0.14875"
paste('Test Error: ', test_err)
## [1] "Test Error:  0.181481481481481"

We get a train error of 0.149 which is lower than our prior linear model, but the test error is 0.181 which is higher.

8f) Repeat parts (b) through (e) using a support vector machine with a radial

kernel. Use the default value for gamma.

oj_radial = svm(Purchase ~., data = OJ_train, kernel = 'radial', cost = 0.01, scale = T)
summary(oj_radial)
## 
## Call:
## svm(formula = Purchase ~ ., data = OJ_train, kernel = "radial", cost = 0.01, 
##     scale = T)
## 
## 
## Parameters:
##    SVM-Type:  C-classification 
##  SVM-Kernel:  radial 
##        cost:  0.01 
## 
## Number of Support Vectors:  634
## 
##  ( 319 315 )
## 
## 
## Number of Classes:  2 
## 
## Levels: 
##  CH MM

With our set cost of 0.01, we get a total of 634 support vectors out of 800 observations with 319 for Citrus Hill and 315 for Minute Maid.

train_err = mean(predict(oj_radial, OJ_train) != OJ_train$Purchase)
test_err = mean(predict(oj_radial, OJ_test) != OJ_test$Purchase)
paste('Train Error: ', train_err)
## [1] "Train Error:  0.39375"
paste('Test Error: ', test_err)
## [1] "Test Error:  0.377777777777778"

We get the error rates of 0.393 for training and 0.377 for test, which are worse than the linear models we have used.

cl <- makeCluster(detectCores())
registerDoParallel(cl)
set.seed(1)
costs = seq(0.01, 2, 0.1) #lowering because it will not finish running
ctrl = tune.control(cross = 5)
oj_tune_rad = tune(svm, Purchase~., data=OJ_train, 
               ranges = list(cost = costs,tunecontrol = ctrl), method = 'radial')
summary(oj_tune_rad)
## 
## Parameter tuning of 'svm':
## 
## - sampling method: 10-fold cross validation 
## 
## - best parameters:
##  cost tunecontrol
##  0.51       FALSE
## 
## - best performance: 0.16625 
## 
## - Detailed performance results:
##     cost
## 1   0.01
## 2   0.11
## 3   0.21
## 4   0.31
## 5   0.41
## 6   0.51
## 7   0.61
## 8   0.71
## 9   0.81
## 10  0.91
## 11  1.01
## 12  1.11
## 13  1.21
## 14  1.31
## 15  1.41
## 16  1.51
## 17  1.61
## 18  1.71
## 19  1.81
## 20  1.91
## 21  0.01
## 22  0.11
## 23  0.21
## 24  0.31
## 25  0.41
## 26  0.51
## 27  0.61
## 28  0.71
## 29  0.81
## 30  0.91
## 31  1.01
## 32  1.11
## 33  1.21
## 34  1.31
## 35  1.41
## 36  1.51
## 37  1.61
## 38  1.71
## 39  1.81
## 40  1.91
## 41  0.01
## 42  0.11
## 43  0.21
## 44  0.31
## 45  0.41
## 46  0.51
## 47  0.61
## 48  0.71
## 49  0.81
## 50  0.91
## 51  1.01
## 52  1.11
## 53  1.21
## 54  1.31
## 55  1.41
## 56  1.51
## 57  1.61
## 58  1.71
## 59  1.81
## 60  1.91
## 61  0.01
## 62  0.11
## 63  0.21
## 64  0.31
## 65  0.41
## 66  0.51
## 67  0.61
## 68  0.71
## 69  0.81
## 70  0.91
## 71  1.01
## 72  1.11
## 73  1.21
## 74  1.31
## 75  1.41
## 76  1.51
## 77  1.61
## 78  1.71
## 79  1.81
## 80  1.91
## 81  0.01
## 82  0.11
## 83  0.21
## 84  0.31
## 85  0.41
## 86  0.51
## 87  0.61
## 88  0.71
## 89  0.81
## 90  0.91
## 91  1.01
## 92  1.11
## 93  1.21
## 94  1.31
## 95  1.41
## 96  1.51
## 97  1.61
## 98  1.71
## 99  1.81
## 100 1.91
## 101 0.01
## 102 0.11
## 103 0.21
## 104 0.31
## 105 0.41
## 106 0.51
## 107 0.61
## 108 0.71
## 109 0.81
## 110 0.91
## 111 1.01
## 112 1.11
## 113 1.21
## 114 1.31
## 115 1.41
## 116 1.51
## 117 1.61
## 118 1.71
## 119 1.81
## 120 1.91
## 121 0.01
## 122 0.11
## 123 0.21
## 124 0.31
## 125 0.41
## 126 0.51
## 127 0.61
## 128 0.71
## 129 0.81
## 130 0.91
## 131 1.01
## 132 1.11
## 133 1.21
## 134 1.31
## 135 1.41
## 136 1.51
## 137 1.61
## 138 1.71
## 139 1.81
## 140 1.91
## 141 0.01
## 142 0.11
## 143 0.21
## 144 0.31
## 145 0.41
## 146 0.51
## 147 0.61
## 148 0.71
## 149 0.81
## 150 0.91
## 151 1.01
## 152 1.11
## 153 1.21
## 154 1.31
## 155 1.41
## 156 1.51
## 157 1.61
## 158 1.71
## 159 1.81
## 160 1.91
## 161 0.01
## 162 0.11
## 163 0.21
## 164 0.31
## 165 0.41
## 166 0.51
## 167 0.61
## 168 0.71
## 169 0.81
## 170 0.91
## 171 1.01
## 172 1.11
## 173 1.21
## 174 1.31
## 175 1.41
## 176 1.51
## 177 1.61
## 178 1.71
## 179 1.81
## 180 1.91
## 181 0.01
## 182 0.11
## 183 0.21
## 184 0.31
## 185 0.41
## 186 0.51
## 187 0.61
## 188 0.71
## 189 0.81
## 190 0.91
## 191 1.01
## 192 1.11
## 193 1.21
## 194 1.31
## 195 1.41
## 196 1.51
## 197 1.61
## 198 1.71
## 199 1.81
## 200 1.91
## 201 0.01
## 202 0.11
## 203 0.21
## 204 0.31
## 205 0.41
## 206 0.51
## 207 0.61
## 208 0.71
## 209 0.81
## 210 0.91
## 211 1.01
## 212 1.11
## 213 1.21
## 214 1.31
## 215 1.41
## 216 1.51
## 217 1.61
## 218 1.71
## 219 1.81
## 220 1.91
## 221 0.01
## 222 0.11
## 223 0.21
## 224 0.31
## 225 0.41
## 226 0.51
## 227 0.61
## 228 0.71
## 229 0.81
## 230 0.91
## 231 1.01
## 232 1.11
## 233 1.21
## 234 1.31
## 235 1.41
## 236 1.51
## 237 1.61
## 238 1.71
## 239 1.81
## 240 1.91
## 241 0.01
## 242 0.11
## 243 0.21
## 244 0.31
## 245 0.41
## 246 0.51
## 247 0.61
## 248 0.71
## 249 0.81
## 250 0.91
## 251 1.01
## 252 1.11
## 253 1.21
## 254 1.31
## 255 1.41
## 256 1.51
## 257 1.61
## 258 1.71
## 259 1.81
## 260 1.91
##                                                                                                             tunecontrol
## 1                                                                                                                 FALSE
## 2                                                                                                                 FALSE
## 3                                                                                                                 FALSE
## 4                                                                                                                 FALSE
## 5                                                                                                                 FALSE
## 6                                                                                                                 FALSE
## 7                                                                                                                 FALSE
## 8                                                                                                                 FALSE
## 9                                                                                                                 FALSE
## 10                                                                                                                FALSE
## 11                                                                                                                FALSE
## 12                                                                                                                FALSE
## 13                                                                                                                FALSE
## 14                                                                                                                FALSE
## 15                                                                                                                FALSE
## 16                                                                                                                FALSE
## 17                                                                                                                FALSE
## 18                                                                                                                FALSE
## 19                                                                                                                FALSE
## 20                                                                                                                FALSE
## 21                                                                                                                    1
## 22                                                                                                                    1
## 23                                                                                                                    1
## 24                                                                                                                    1
## 25                                                                                                                    1
## 26                                                                                                                    1
## 27                                                                                                                    1
## 28                                                                                                                    1
## 29                                                                                                                    1
## 30                                                                                                                    1
## 31                                                                                                                    1
## 32                                                                                                                    1
## 33                                                                                                                    1
## 34                                                                                                                    1
## 35                                                                                                                    1
## 36                                                                                                                    1
## 37                                                                                                                    1
## 38                                                                                                                    1
## 39                                                                                                                    1
## 40                                                                                                                    1
## 41                                                                                function (x, ...) , UseMethod("mean")
## 42                                                                                function (x, ...) , UseMethod("mean")
## 43                                                                                function (x, ...) , UseMethod("mean")
## 44                                                                                function (x, ...) , UseMethod("mean")
## 45                                                                                function (x, ...) , UseMethod("mean")
## 46                                                                                function (x, ...) , UseMethod("mean")
## 47                                                                                function (x, ...) , UseMethod("mean")
## 48                                                                                function (x, ...) , UseMethod("mean")
## 49                                                                                function (x, ...) , UseMethod("mean")
## 50                                                                                function (x, ...) , UseMethod("mean")
## 51                                                                                function (x, ...) , UseMethod("mean")
## 52                                                                                function (x, ...) , UseMethod("mean")
## 53                                                                                function (x, ...) , UseMethod("mean")
## 54                                                                                function (x, ...) , UseMethod("mean")
## 55                                                                                function (x, ...) , UseMethod("mean")
## 56                                                                                function (x, ...) , UseMethod("mean")
## 57                                                                                function (x, ...) , UseMethod("mean")
## 58                                                                                function (x, ...) , UseMethod("mean")
## 59                                                                                function (x, ...) , UseMethod("mean")
## 60                                                                                function (x, ...) , UseMethod("mean")
## 61                                                                                                                cross
## 62                                                                                                                cross
## 63                                                                                                                cross
## 64                                                                                                                cross
## 65                                                                                                                cross
## 66                                                                                                                cross
## 67                                                                                                                cross
## 68                                                                                                                cross
## 69                                                                                                                cross
## 70                                                                                                                cross
## 71                                                                                                                cross
## 72                                                                                                                cross
## 73                                                                                                                cross
## 74                                                                                                                cross
## 75                                                                                                                cross
## 76                                                                                                                cross
## 77                                                                                                                cross
## 78                                                                                                                cross
## 79                                                                                                                cross
## 80                                                                                                                cross
## 81                                                                                function (x, ...) , UseMethod("mean")
## 82                                                                                function (x, ...) , UseMethod("mean")
## 83                                                                                function (x, ...) , UseMethod("mean")
## 84                                                                                function (x, ...) , UseMethod("mean")
## 85                                                                                function (x, ...) , UseMethod("mean")
## 86                                                                                function (x, ...) , UseMethod("mean")
## 87                                                                                function (x, ...) , UseMethod("mean")
## 88                                                                                function (x, ...) , UseMethod("mean")
## 89                                                                                function (x, ...) , UseMethod("mean")
## 90                                                                                function (x, ...) , UseMethod("mean")
## 91                                                                                function (x, ...) , UseMethod("mean")
## 92                                                                                function (x, ...) , UseMethod("mean")
## 93                                                                                function (x, ...) , UseMethod("mean")
## 94                                                                                function (x, ...) , UseMethod("mean")
## 95                                                                                function (x, ...) , UseMethod("mean")
## 96                                                                                function (x, ...) , UseMethod("mean")
## 97                                                                                function (x, ...) , UseMethod("mean")
## 98                                                                                function (x, ...) , UseMethod("mean")
## 99                                                                                function (x, ...) , UseMethod("mean")
## 100                                                                               function (x, ...) , UseMethod("mean")
## 101 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 102 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 103 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 104 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 105 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 106 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 107 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 108 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 109 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 110 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 111 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 112 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 113 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 114 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 115 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 116 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 117 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 118 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 119 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 120 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 121                                                                                                                   5
## 122                                                                                                                   5
## 123                                                                                                                   5
## 124                                                                                                                   5
## 125                                                                                                                   5
## 126                                                                                                                   5
## 127                                                                                                                   5
## 128                                                                                                                   5
## 129                                                                                                                   5
## 130                                                                                                                   5
## 131                                                                                                                   5
## 132                                                                                                                   5
## 133                                                                                                                   5
## 134                                                                                                                   5
## 135                                                                                                                   5
## 136                                                                                                                   5
## 137                                                                                                                   5
## 138                                                                                                                   5
## 139                                                                                                                   5
## 140                                                                                                                   5
## 141                                                                                                           0.6666667
## 142                                                                                                           0.6666667
## 143                                                                                                           0.6666667
## 144                                                                                                           0.6666667
## 145                                                                                                           0.6666667
## 146                                                                                                           0.6666667
## 147                                                                                                           0.6666667
## 148                                                                                                           0.6666667
## 149                                                                                                           0.6666667
## 150                                                                                                           0.6666667
## 151                                                                                                           0.6666667
## 152                                                                                                           0.6666667
## 153                                                                                                           0.6666667
## 154                                                                                                           0.6666667
## 155                                                                                                           0.6666667
## 156                                                                                                           0.6666667
## 157                                                                                                           0.6666667
## 158                                                                                                           0.6666667
## 159                                                                                                           0.6666667
## 160                                                                                                           0.6666667
## 161                                                                                                                  10
## 162                                                                                                                  10
## 163                                                                                                                  10
## 164                                                                                                                  10
## 165                                                                                                                  10
## 166                                                                                                                  10
## 167                                                                                                                  10
## 168                                                                                                                  10
## 169                                                                                                                  10
## 170                                                                                                                  10
## 171                                                                                                                  10
## 172                                                                                                                  10
## 173                                                                                                                  10
## 174                                                                                                                  10
## 175                                                                                                                  10
## 176                                                                                                                  10
## 177                                                                                                                  10
## 178                                                                                                                  10
## 179                                                                                                                  10
## 180                                                                                                                  10
## 181                                                                                                                 0.9
## 182                                                                                                                 0.9
## 183                                                                                                                 0.9
## 184                                                                                                                 0.9
## 185                                                                                                                 0.9
## 186                                                                                                                 0.9
## 187                                                                                                                 0.9
## 188                                                                                                                 0.9
## 189                                                                                                                 0.9
## 190                                                                                                                 0.9
## 191                                                                                                                 0.9
## 192                                                                                                                 0.9
## 193                                                                                                                 0.9
## 194                                                                                                                 0.9
## 195                                                                                                                 0.9
## 196                                                                                                                 0.9
## 197                                                                                                                 0.9
## 198                                                                                                                 0.9
## 199                                                                                                                 0.9
## 200                                                                                                                 0.9
## 201                                                                                                                TRUE
## 202                                                                                                                TRUE
## 203                                                                                                                TRUE
## 204                                                                                                                TRUE
## 205                                                                                                                TRUE
## 206                                                                                                                TRUE
## 207                                                                                                                TRUE
## 208                                                                                                                TRUE
## 209                                                                                                                TRUE
## 210                                                                                                                TRUE
## 211                                                                                                                TRUE
## 212                                                                                                                TRUE
## 213                                                                                                                TRUE
## 214                                                                                                                TRUE
## 215                                                                                                                TRUE
## 216                                                                                                                TRUE
## 217                                                                                                                TRUE
## 218                                                                                                                TRUE
## 219                                                                                                                TRUE
## 220                                                                                                                TRUE
## 221                                                                                                                TRUE
## 222                                                                                                                TRUE
## 223                                                                                                                TRUE
## 224                                                                                                                TRUE
## 225                                                                                                                TRUE
## 226                                                                                                                TRUE
## 227                                                                                                                TRUE
## 228                                                                                                                TRUE
## 229                                                                                                                TRUE
## 230                                                                                                                TRUE
## 231                                                                                                                TRUE
## 232                                                                                                                TRUE
## 233                                                                                                                TRUE
## 234                                                                                                                TRUE
## 235                                                                                                                TRUE
## 236                                                                                                                TRUE
## 237                                                                                                                TRUE
## 238                                                                                                                TRUE
## 239                                                                                                                TRUE
## 240                                                                                                                TRUE
## 241                                                                                                                NULL
## 242                                                                                                                NULL
## 243                                                                                                                NULL
## 244                                                                                                                NULL
## 245                                                                                                                NULL
## 246                                                                                                                NULL
## 247                                                                                                                NULL
## 248                                                                                                                NULL
## 249                                                                                                                NULL
## 250                                                                                                                NULL
## 251                                                                                                                NULL
## 252                                                                                                                NULL
## 253                                                                                                                NULL
## 254                                                                                                                NULL
## 255                                                                                                                NULL
## 256                                                                                                                NULL
## 257                                                                                                                NULL
## 258                                                                                                                NULL
## 259                                                                                                                NULL
## 260                                                                                                                NULL
##       error dispersion
## 1   0.39375 0.04007372
## 2   0.18625 0.02853482
## 3   0.18250 0.03238227
## 4   0.17875 0.03230175
## 5   0.17625 0.02531057
## 6   0.16625 0.02433134
## 7   0.16875 0.02301117
## 8   0.16750 0.02776389
## 9   0.17000 0.02513851
## 10  0.16750 0.02220485
## 11  0.17125 0.02128673
## 12  0.17125 0.01958777
## 13  0.17250 0.02108185
## 14  0.17375 0.02161050
## 15  0.17375 0.02389938
## 16  0.17625 0.02161050
## 17  0.17625 0.02161050
## 18  0.17750 0.02188988
## 19  0.17625 0.02079162
## 20  0.17625 0.02079162
## 21  0.39375 0.04007372
## 22  0.18625 0.02853482
## 23  0.18250 0.03238227
## 24  0.17875 0.03230175
## 25  0.17625 0.02531057
## 26  0.16625 0.02433134
## 27  0.16875 0.02301117
## 28  0.16750 0.02776389
## 29  0.17000 0.02513851
## 30  0.16750 0.02220485
## 31  0.17125 0.02128673
## 32  0.17125 0.01958777
## 33  0.17250 0.02108185
## 34  0.17375 0.02161050
## 35  0.17375 0.02389938
## 36  0.17625 0.02161050
## 37  0.17625 0.02161050
## 38  0.17750 0.02188988
## 39  0.17625 0.02079162
## 40  0.17625 0.02079162
## 41  0.39375 0.04007372
## 42  0.18625 0.02853482
## 43  0.18250 0.03238227
## 44  0.17875 0.03230175
## 45  0.17625 0.02531057
## 46  0.16625 0.02433134
## 47  0.16875 0.02301117
## 48  0.16750 0.02776389
## 49  0.17000 0.02513851
## 50  0.16750 0.02220485
## 51  0.17125 0.02128673
## 52  0.17125 0.01958777
## 53  0.17250 0.02108185
## 54  0.17375 0.02161050
## 55  0.17375 0.02389938
## 56  0.17625 0.02161050
## 57  0.17625 0.02161050
## 58  0.17750 0.02188988
## 59  0.17625 0.02079162
## 60  0.17625 0.02079162
## 61  0.39375 0.04007372
## 62  0.18625 0.02853482
## 63  0.18250 0.03238227
## 64  0.17875 0.03230175
## 65  0.17625 0.02531057
## 66  0.16625 0.02433134
## 67  0.16875 0.02301117
## 68  0.16750 0.02776389
## 69  0.17000 0.02513851
## 70  0.16750 0.02220485
## 71  0.17125 0.02128673
## 72  0.17125 0.01958777
## 73  0.17250 0.02108185
## 74  0.17375 0.02161050
## 75  0.17375 0.02389938
## 76  0.17625 0.02161050
## 77  0.17625 0.02161050
## 78  0.17750 0.02188988
## 79  0.17625 0.02079162
## 80  0.17625 0.02079162
## 81  0.39375 0.04007372
## 82  0.18625 0.02853482
## 83  0.18250 0.03238227
## 84  0.17875 0.03230175
## 85  0.17625 0.02531057
## 86  0.16625 0.02433134
## 87  0.16875 0.02301117
## 88  0.16750 0.02776389
## 89  0.17000 0.02513851
## 90  0.16750 0.02220485
## 91  0.17125 0.02128673
## 92  0.17125 0.01958777
## 93  0.17250 0.02108185
## 94  0.17375 0.02161050
## 95  0.17375 0.02389938
## 96  0.17625 0.02161050
## 97  0.17625 0.02161050
## 98  0.17750 0.02188988
## 99  0.17625 0.02079162
## 100 0.17625 0.02079162
## 101 0.39375 0.04007372
## 102 0.18625 0.02853482
## 103 0.18250 0.03238227
## 104 0.17875 0.03230175
## 105 0.17625 0.02531057
## 106 0.16625 0.02433134
## 107 0.16875 0.02301117
## 108 0.16750 0.02776389
## 109 0.17000 0.02513851
## 110 0.16750 0.02220485
## 111 0.17125 0.02128673
## 112 0.17125 0.01958777
## 113 0.17250 0.02108185
## 114 0.17375 0.02161050
## 115 0.17375 0.02389938
## 116 0.17625 0.02161050
## 117 0.17625 0.02161050
## 118 0.17750 0.02188988
## 119 0.17625 0.02079162
## 120 0.17625 0.02079162
## 121 0.39375 0.04007372
## 122 0.18625 0.02853482
## 123 0.18250 0.03238227
## 124 0.17875 0.03230175
## 125 0.17625 0.02531057
## 126 0.16625 0.02433134
## 127 0.16875 0.02301117
## 128 0.16750 0.02776389
## 129 0.17000 0.02513851
## 130 0.16750 0.02220485
## 131 0.17125 0.02128673
## 132 0.17125 0.01958777
## 133 0.17250 0.02108185
## 134 0.17375 0.02161050
## 135 0.17375 0.02389938
## 136 0.17625 0.02161050
## 137 0.17625 0.02161050
## 138 0.17750 0.02188988
## 139 0.17625 0.02079162
## 140 0.17625 0.02079162
## 141 0.39375 0.04007372
## 142 0.18625 0.02853482
## 143 0.18250 0.03238227
## 144 0.17875 0.03230175
## 145 0.17625 0.02531057
## 146 0.16625 0.02433134
## 147 0.16875 0.02301117
## 148 0.16750 0.02776389
## 149 0.17000 0.02513851
## 150 0.16750 0.02220485
## 151 0.17125 0.02128673
## 152 0.17125 0.01958777
## 153 0.17250 0.02108185
## 154 0.17375 0.02161050
## 155 0.17375 0.02389938
## 156 0.17625 0.02161050
## 157 0.17625 0.02161050
## 158 0.17750 0.02188988
## 159 0.17625 0.02079162
## 160 0.17625 0.02079162
## 161 0.39375 0.04007372
## 162 0.18625 0.02853482
## 163 0.18250 0.03238227
## 164 0.17875 0.03230175
## 165 0.17625 0.02531057
## 166 0.16625 0.02433134
## 167 0.16875 0.02301117
## 168 0.16750 0.02776389
## 169 0.17000 0.02513851
## 170 0.16750 0.02220485
## 171 0.17125 0.02128673
## 172 0.17125 0.01958777
## 173 0.17250 0.02108185
## 174 0.17375 0.02161050
## 175 0.17375 0.02389938
## 176 0.17625 0.02161050
## 177 0.17625 0.02161050
## 178 0.17750 0.02188988
## 179 0.17625 0.02079162
## 180 0.17625 0.02079162
## 181 0.39375 0.04007372
## 182 0.18625 0.02853482
## 183 0.18250 0.03238227
## 184 0.17875 0.03230175
## 185 0.17625 0.02531057
## 186 0.16625 0.02433134
## 187 0.16875 0.02301117
## 188 0.16750 0.02776389
## 189 0.17000 0.02513851
## 190 0.16750 0.02220485
## 191 0.17125 0.02128673
## 192 0.17125 0.01958777
## 193 0.17250 0.02108185
## 194 0.17375 0.02161050
## 195 0.17375 0.02389938
## 196 0.17625 0.02161050
## 197 0.17625 0.02161050
## 198 0.17750 0.02188988
## 199 0.17625 0.02079162
## 200 0.17625 0.02079162
## 201 0.39375 0.04007372
## 202 0.18625 0.02853482
## 203 0.18250 0.03238227
## 204 0.17875 0.03230175
## 205 0.17625 0.02531057
## 206 0.16625 0.02433134
## 207 0.16875 0.02301117
## 208 0.16750 0.02776389
## 209 0.17000 0.02513851
## 210 0.16750 0.02220485
## 211 0.17125 0.02128673
## 212 0.17125 0.01958777
## 213 0.17250 0.02108185
## 214 0.17375 0.02161050
## 215 0.17375 0.02389938
## 216 0.17625 0.02161050
## 217 0.17625 0.02161050
## 218 0.17750 0.02188988
## 219 0.17625 0.02079162
## 220 0.17625 0.02079162
## 221 0.39375 0.04007372
## 222 0.18625 0.02853482
## 223 0.18250 0.03238227
## 224 0.17875 0.03230175
## 225 0.17625 0.02531057
## 226 0.16625 0.02433134
## 227 0.16875 0.02301117
## 228 0.16750 0.02776389
## 229 0.17000 0.02513851
## 230 0.16750 0.02220485
## 231 0.17125 0.02128673
## 232 0.17125 0.01958777
## 233 0.17250 0.02108185
## 234 0.17375 0.02161050
## 235 0.17375 0.02389938
## 236 0.17625 0.02161050
## 237 0.17625 0.02161050
## 238 0.17750 0.02188988
## 239 0.17625 0.02079162
## 240 0.17625 0.02079162
## 241 0.39375 0.04007372
## 242 0.18625 0.02853482
## 243 0.18250 0.03238227
## 244 0.17875 0.03230175
## 245 0.17625 0.02531057
## 246 0.16625 0.02433134
## 247 0.16875 0.02301117
## 248 0.16750 0.02776389
## 249 0.17000 0.02513851
## 250 0.16750 0.02220485
## 251 0.17125 0.02128673
## 252 0.17125 0.01958777
## 253 0.17250 0.02108185
## 254 0.17375 0.02161050
## 255 0.17375 0.02389938
## 256 0.17625 0.02161050
## 257 0.17625 0.02161050
## 258 0.17750 0.02188988
## 259 0.17625 0.02079162
## 260 0.17625 0.02079162
stopCluster(cl)

We get an error rate of 0.166 with the best cost of 0.51.

train_err = mean(predict(oj_tune_rad$best.model, OJ_train) != OJ_train$Purchase)
test_err = mean(predict(oj_tune_rad$best.model, OJ_test) != OJ_test$Purchase)
paste('Train Error: ', train_err)
## [1] "Train Error:  0.14875"
paste('Test Error: ', test_err)
## [1] "Test Error:  0.177777777777778"

When we use tuned hyper-parameters for radial, we get better results. Our train error went down to 0.149 and a test error of 0.177 which is the same as our current best linear model.

8g) Repeat parts (b) through (e) using a support vector machine

with a polynomial kernel. Set degree = 2.

oj_poly = svm(Purchase ~., data = OJ_train, kernel = 'polynomial',
              cost = 0.01, scale = T, degree = 2)
summary(oj_poly)
## 
## Call:
## svm(formula = Purchase ~ ., data = OJ_train, kernel = "polynomial", 
##     cost = 0.01, degree = 2, scale = T)
## 
## 
## Parameters:
##    SVM-Type:  C-classification 
##  SVM-Kernel:  polynomial 
##        cost:  0.01 
##      degree:  2 
##      coef.0:  0 
## 
## Number of Support Vectors:  636
## 
##  ( 321 315 )
## 
## 
## Number of Classes:  2 
## 
## Levels: 
##  CH MM

With our cost of 0.01 on a polynomial of 2, we get 636 support vectors with 321 belonging to Citrus Hill and 315 belonging to Minute Maid.

train_err = mean(predict(oj_poly, OJ_train) != OJ_train$Purchase)
test_err = mean(predict(oj_poly, OJ_test) != OJ_test$Purchase)
paste('Train Error: ', train_err)
## [1] "Train Error:  0.3725"
paste('Test Error: ', test_err)
## [1] "Test Error:  0.366666666666667"

We get the error rates of 0.372 for training and 0.366 which are not as good as our prior models.

set.seed(1)
cl <- makeCluster(detectCores())
registerDoParallel(cl)
costs = seq(0.01, 2, 0.1) #changing because it taking too long to run
ctrl = tune.control(cross = 5)
oj_tune_poly = tune(svm, Purchase~., data=OJ_train, 
               ranges = list(cost = costs,tunecontrol = ctrl), method = 'polynomial',
               degree = 2)
summary(oj_tune_poly)
## 
## Parameter tuning of 'svm':
## 
## - sampling method: 10-fold cross validation 
## 
## - best parameters:
##  cost tunecontrol
##  0.51       FALSE
## 
## - best performance: 0.16625 
## 
## - Detailed performance results:
##     cost
## 1   0.01
## 2   0.11
## 3   0.21
## 4   0.31
## 5   0.41
## 6   0.51
## 7   0.61
## 8   0.71
## 9   0.81
## 10  0.91
## 11  1.01
## 12  1.11
## 13  1.21
## 14  1.31
## 15  1.41
## 16  1.51
## 17  1.61
## 18  1.71
## 19  1.81
## 20  1.91
## 21  0.01
## 22  0.11
## 23  0.21
## 24  0.31
## 25  0.41
## 26  0.51
## 27  0.61
## 28  0.71
## 29  0.81
## 30  0.91
## 31  1.01
## 32  1.11
## 33  1.21
## 34  1.31
## 35  1.41
## 36  1.51
## 37  1.61
## 38  1.71
## 39  1.81
## 40  1.91
## 41  0.01
## 42  0.11
## 43  0.21
## 44  0.31
## 45  0.41
## 46  0.51
## 47  0.61
## 48  0.71
## 49  0.81
## 50  0.91
## 51  1.01
## 52  1.11
## 53  1.21
## 54  1.31
## 55  1.41
## 56  1.51
## 57  1.61
## 58  1.71
## 59  1.81
## 60  1.91
## 61  0.01
## 62  0.11
## 63  0.21
## 64  0.31
## 65  0.41
## 66  0.51
## 67  0.61
## 68  0.71
## 69  0.81
## 70  0.91
## 71  1.01
## 72  1.11
## 73  1.21
## 74  1.31
## 75  1.41
## 76  1.51
## 77  1.61
## 78  1.71
## 79  1.81
## 80  1.91
## 81  0.01
## 82  0.11
## 83  0.21
## 84  0.31
## 85  0.41
## 86  0.51
## 87  0.61
## 88  0.71
## 89  0.81
## 90  0.91
## 91  1.01
## 92  1.11
## 93  1.21
## 94  1.31
## 95  1.41
## 96  1.51
## 97  1.61
## 98  1.71
## 99  1.81
## 100 1.91
## 101 0.01
## 102 0.11
## 103 0.21
## 104 0.31
## 105 0.41
## 106 0.51
## 107 0.61
## 108 0.71
## 109 0.81
## 110 0.91
## 111 1.01
## 112 1.11
## 113 1.21
## 114 1.31
## 115 1.41
## 116 1.51
## 117 1.61
## 118 1.71
## 119 1.81
## 120 1.91
## 121 0.01
## 122 0.11
## 123 0.21
## 124 0.31
## 125 0.41
## 126 0.51
## 127 0.61
## 128 0.71
## 129 0.81
## 130 0.91
## 131 1.01
## 132 1.11
## 133 1.21
## 134 1.31
## 135 1.41
## 136 1.51
## 137 1.61
## 138 1.71
## 139 1.81
## 140 1.91
## 141 0.01
## 142 0.11
## 143 0.21
## 144 0.31
## 145 0.41
## 146 0.51
## 147 0.61
## 148 0.71
## 149 0.81
## 150 0.91
## 151 1.01
## 152 1.11
## 153 1.21
## 154 1.31
## 155 1.41
## 156 1.51
## 157 1.61
## 158 1.71
## 159 1.81
## 160 1.91
## 161 0.01
## 162 0.11
## 163 0.21
## 164 0.31
## 165 0.41
## 166 0.51
## 167 0.61
## 168 0.71
## 169 0.81
## 170 0.91
## 171 1.01
## 172 1.11
## 173 1.21
## 174 1.31
## 175 1.41
## 176 1.51
## 177 1.61
## 178 1.71
## 179 1.81
## 180 1.91
## 181 0.01
## 182 0.11
## 183 0.21
## 184 0.31
## 185 0.41
## 186 0.51
## 187 0.61
## 188 0.71
## 189 0.81
## 190 0.91
## 191 1.01
## 192 1.11
## 193 1.21
## 194 1.31
## 195 1.41
## 196 1.51
## 197 1.61
## 198 1.71
## 199 1.81
## 200 1.91
## 201 0.01
## 202 0.11
## 203 0.21
## 204 0.31
## 205 0.41
## 206 0.51
## 207 0.61
## 208 0.71
## 209 0.81
## 210 0.91
## 211 1.01
## 212 1.11
## 213 1.21
## 214 1.31
## 215 1.41
## 216 1.51
## 217 1.61
## 218 1.71
## 219 1.81
## 220 1.91
## 221 0.01
## 222 0.11
## 223 0.21
## 224 0.31
## 225 0.41
## 226 0.51
## 227 0.61
## 228 0.71
## 229 0.81
## 230 0.91
## 231 1.01
## 232 1.11
## 233 1.21
## 234 1.31
## 235 1.41
## 236 1.51
## 237 1.61
## 238 1.71
## 239 1.81
## 240 1.91
## 241 0.01
## 242 0.11
## 243 0.21
## 244 0.31
## 245 0.41
## 246 0.51
## 247 0.61
## 248 0.71
## 249 0.81
## 250 0.91
## 251 1.01
## 252 1.11
## 253 1.21
## 254 1.31
## 255 1.41
## 256 1.51
## 257 1.61
## 258 1.71
## 259 1.81
## 260 1.91
##                                                                                                             tunecontrol
## 1                                                                                                                 FALSE
## 2                                                                                                                 FALSE
## 3                                                                                                                 FALSE
## 4                                                                                                                 FALSE
## 5                                                                                                                 FALSE
## 6                                                                                                                 FALSE
## 7                                                                                                                 FALSE
## 8                                                                                                                 FALSE
## 9                                                                                                                 FALSE
## 10                                                                                                                FALSE
## 11                                                                                                                FALSE
## 12                                                                                                                FALSE
## 13                                                                                                                FALSE
## 14                                                                                                                FALSE
## 15                                                                                                                FALSE
## 16                                                                                                                FALSE
## 17                                                                                                                FALSE
## 18                                                                                                                FALSE
## 19                                                                                                                FALSE
## 20                                                                                                                FALSE
## 21                                                                                                                    1
## 22                                                                                                                    1
## 23                                                                                                                    1
## 24                                                                                                                    1
## 25                                                                                                                    1
## 26                                                                                                                    1
## 27                                                                                                                    1
## 28                                                                                                                    1
## 29                                                                                                                    1
## 30                                                                                                                    1
## 31                                                                                                                    1
## 32                                                                                                                    1
## 33                                                                                                                    1
## 34                                                                                                                    1
## 35                                                                                                                    1
## 36                                                                                                                    1
## 37                                                                                                                    1
## 38                                                                                                                    1
## 39                                                                                                                    1
## 40                                                                                                                    1
## 41                                                                                function (x, ...) , UseMethod("mean")
## 42                                                                                function (x, ...) , UseMethod("mean")
## 43                                                                                function (x, ...) , UseMethod("mean")
## 44                                                                                function (x, ...) , UseMethod("mean")
## 45                                                                                function (x, ...) , UseMethod("mean")
## 46                                                                                function (x, ...) , UseMethod("mean")
## 47                                                                                function (x, ...) , UseMethod("mean")
## 48                                                                                function (x, ...) , UseMethod("mean")
## 49                                                                                function (x, ...) , UseMethod("mean")
## 50                                                                                function (x, ...) , UseMethod("mean")
## 51                                                                                function (x, ...) , UseMethod("mean")
## 52                                                                                function (x, ...) , UseMethod("mean")
## 53                                                                                function (x, ...) , UseMethod("mean")
## 54                                                                                function (x, ...) , UseMethod("mean")
## 55                                                                                function (x, ...) , UseMethod("mean")
## 56                                                                                function (x, ...) , UseMethod("mean")
## 57                                                                                function (x, ...) , UseMethod("mean")
## 58                                                                                function (x, ...) , UseMethod("mean")
## 59                                                                                function (x, ...) , UseMethod("mean")
## 60                                                                                function (x, ...) , UseMethod("mean")
## 61                                                                                                                cross
## 62                                                                                                                cross
## 63                                                                                                                cross
## 64                                                                                                                cross
## 65                                                                                                                cross
## 66                                                                                                                cross
## 67                                                                                                                cross
## 68                                                                                                                cross
## 69                                                                                                                cross
## 70                                                                                                                cross
## 71                                                                                                                cross
## 72                                                                                                                cross
## 73                                                                                                                cross
## 74                                                                                                                cross
## 75                                                                                                                cross
## 76                                                                                                                cross
## 77                                                                                                                cross
## 78                                                                                                                cross
## 79                                                                                                                cross
## 80                                                                                                                cross
## 81                                                                                function (x, ...) , UseMethod("mean")
## 82                                                                                function (x, ...) , UseMethod("mean")
## 83                                                                                function (x, ...) , UseMethod("mean")
## 84                                                                                function (x, ...) , UseMethod("mean")
## 85                                                                                function (x, ...) , UseMethod("mean")
## 86                                                                                function (x, ...) , UseMethod("mean")
## 87                                                                                function (x, ...) , UseMethod("mean")
## 88                                                                                function (x, ...) , UseMethod("mean")
## 89                                                                                function (x, ...) , UseMethod("mean")
## 90                                                                                function (x, ...) , UseMethod("mean")
## 91                                                                                function (x, ...) , UseMethod("mean")
## 92                                                                                function (x, ...) , UseMethod("mean")
## 93                                                                                function (x, ...) , UseMethod("mean")
## 94                                                                                function (x, ...) , UseMethod("mean")
## 95                                                                                function (x, ...) , UseMethod("mean")
## 96                                                                                function (x, ...) , UseMethod("mean")
## 97                                                                                function (x, ...) , UseMethod("mean")
## 98                                                                                function (x, ...) , UseMethod("mean")
## 99                                                                                function (x, ...) , UseMethod("mean")
## 100                                                                               function (x, ...) , UseMethod("mean")
## 101 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 102 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 103 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 104 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 105 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 106 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 107 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 108 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 109 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 110 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 111 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 112 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 113 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 114 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 115 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 116 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 117 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 118 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 119 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 120 function (x, na.rm = FALSE) , sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), ,     na.rm = na.rm))
## 121                                                                                                                   5
## 122                                                                                                                   5
## 123                                                                                                                   5
## 124                                                                                                                   5
## 125                                                                                                                   5
## 126                                                                                                                   5
## 127                                                                                                                   5
## 128                                                                                                                   5
## 129                                                                                                                   5
## 130                                                                                                                   5
## 131                                                                                                                   5
## 132                                                                                                                   5
## 133                                                                                                                   5
## 134                                                                                                                   5
## 135                                                                                                                   5
## 136                                                                                                                   5
## 137                                                                                                                   5
## 138                                                                                                                   5
## 139                                                                                                                   5
## 140                                                                                                                   5
## 141                                                                                                           0.6666667
## 142                                                                                                           0.6666667
## 143                                                                                                           0.6666667
## 144                                                                                                           0.6666667
## 145                                                                                                           0.6666667
## 146                                                                                                           0.6666667
## 147                                                                                                           0.6666667
## 148                                                                                                           0.6666667
## 149                                                                                                           0.6666667
## 150                                                                                                           0.6666667
## 151                                                                                                           0.6666667
## 152                                                                                                           0.6666667
## 153                                                                                                           0.6666667
## 154                                                                                                           0.6666667
## 155                                                                                                           0.6666667
## 156                                                                                                           0.6666667
## 157                                                                                                           0.6666667
## 158                                                                                                           0.6666667
## 159                                                                                                           0.6666667
## 160                                                                                                           0.6666667
## 161                                                                                                                  10
## 162                                                                                                                  10
## 163                                                                                                                  10
## 164                                                                                                                  10
## 165                                                                                                                  10
## 166                                                                                                                  10
## 167                                                                                                                  10
## 168                                                                                                                  10
## 169                                                                                                                  10
## 170                                                                                                                  10
## 171                                                                                                                  10
## 172                                                                                                                  10
## 173                                                                                                                  10
## 174                                                                                                                  10
## 175                                                                                                                  10
## 176                                                                                                                  10
## 177                                                                                                                  10
## 178                                                                                                                  10
## 179                                                                                                                  10
## 180                                                                                                                  10
## 181                                                                                                                 0.9
## 182                                                                                                                 0.9
## 183                                                                                                                 0.9
## 184                                                                                                                 0.9
## 185                                                                                                                 0.9
## 186                                                                                                                 0.9
## 187                                                                                                                 0.9
## 188                                                                                                                 0.9
## 189                                                                                                                 0.9
## 190                                                                                                                 0.9
## 191                                                                                                                 0.9
## 192                                                                                                                 0.9
## 193                                                                                                                 0.9
## 194                                                                                                                 0.9
## 195                                                                                                                 0.9
## 196                                                                                                                 0.9
## 197                                                                                                                 0.9
## 198                                                                                                                 0.9
## 199                                                                                                                 0.9
## 200                                                                                                                 0.9
## 201                                                                                                                TRUE
## 202                                                                                                                TRUE
## 203                                                                                                                TRUE
## 204                                                                                                                TRUE
## 205                                                                                                                TRUE
## 206                                                                                                                TRUE
## 207                                                                                                                TRUE
## 208                                                                                                                TRUE
## 209                                                                                                                TRUE
## 210                                                                                                                TRUE
## 211                                                                                                                TRUE
## 212                                                                                                                TRUE
## 213                                                                                                                TRUE
## 214                                                                                                                TRUE
## 215                                                                                                                TRUE
## 216                                                                                                                TRUE
## 217                                                                                                                TRUE
## 218                                                                                                                TRUE
## 219                                                                                                                TRUE
## 220                                                                                                                TRUE
## 221                                                                                                                TRUE
## 222                                                                                                                TRUE
## 223                                                                                                                TRUE
## 224                                                                                                                TRUE
## 225                                                                                                                TRUE
## 226                                                                                                                TRUE
## 227                                                                                                                TRUE
## 228                                                                                                                TRUE
## 229                                                                                                                TRUE
## 230                                                                                                                TRUE
## 231                                                                                                                TRUE
## 232                                                                                                                TRUE
## 233                                                                                                                TRUE
## 234                                                                                                                TRUE
## 235                                                                                                                TRUE
## 236                                                                                                                TRUE
## 237                                                                                                                TRUE
## 238                                                                                                                TRUE
## 239                                                                                                                TRUE
## 240                                                                                                                TRUE
## 241                                                                                                                NULL
## 242                                                                                                                NULL
## 243                                                                                                                NULL
## 244                                                                                                                NULL
## 245                                                                                                                NULL
## 246                                                                                                                NULL
## 247                                                                                                                NULL
## 248                                                                                                                NULL
## 249                                                                                                                NULL
## 250                                                                                                                NULL
## 251                                                                                                                NULL
## 252                                                                                                                NULL
## 253                                                                                                                NULL
## 254                                                                                                                NULL
## 255                                                                                                                NULL
## 256                                                                                                                NULL
## 257                                                                                                                NULL
## 258                                                                                                                NULL
## 259                                                                                                                NULL
## 260                                                                                                                NULL
##       error dispersion
## 1   0.39375 0.04007372
## 2   0.18625 0.02853482
## 3   0.18250 0.03238227
## 4   0.17875 0.03230175
## 5   0.17625 0.02531057
## 6   0.16625 0.02433134
## 7   0.16875 0.02301117
## 8   0.16750 0.02776389
## 9   0.17000 0.02513851
## 10  0.16750 0.02220485
## 11  0.17125 0.02128673
## 12  0.17125 0.01958777
## 13  0.17250 0.02108185
## 14  0.17375 0.02161050
## 15  0.17375 0.02389938
## 16  0.17625 0.02161050
## 17  0.17625 0.02161050
## 18  0.17750 0.02188988
## 19  0.17625 0.02079162
## 20  0.17625 0.02079162
## 21  0.39375 0.04007372
## 22  0.18625 0.02853482
## 23  0.18250 0.03238227
## 24  0.17875 0.03230175
## 25  0.17625 0.02531057
## 26  0.16625 0.02433134
## 27  0.16875 0.02301117
## 28  0.16750 0.02776389
## 29  0.17000 0.02513851
## 30  0.16750 0.02220485
## 31  0.17125 0.02128673
## 32  0.17125 0.01958777
## 33  0.17250 0.02108185
## 34  0.17375 0.02161050
## 35  0.17375 0.02389938
## 36  0.17625 0.02161050
## 37  0.17625 0.02161050
## 38  0.17750 0.02188988
## 39  0.17625 0.02079162
## 40  0.17625 0.02079162
## 41  0.39375 0.04007372
## 42  0.18625 0.02853482
## 43  0.18250 0.03238227
## 44  0.17875 0.03230175
## 45  0.17625 0.02531057
## 46  0.16625 0.02433134
## 47  0.16875 0.02301117
## 48  0.16750 0.02776389
## 49  0.17000 0.02513851
## 50  0.16750 0.02220485
## 51  0.17125 0.02128673
## 52  0.17125 0.01958777
## 53  0.17250 0.02108185
## 54  0.17375 0.02161050
## 55  0.17375 0.02389938
## 56  0.17625 0.02161050
## 57  0.17625 0.02161050
## 58  0.17750 0.02188988
## 59  0.17625 0.02079162
## 60  0.17625 0.02079162
## 61  0.39375 0.04007372
## 62  0.18625 0.02853482
## 63  0.18250 0.03238227
## 64  0.17875 0.03230175
## 65  0.17625 0.02531057
## 66  0.16625 0.02433134
## 67  0.16875 0.02301117
## 68  0.16750 0.02776389
## 69  0.17000 0.02513851
## 70  0.16750 0.02220485
## 71  0.17125 0.02128673
## 72  0.17125 0.01958777
## 73  0.17250 0.02108185
## 74  0.17375 0.02161050
## 75  0.17375 0.02389938
## 76  0.17625 0.02161050
## 77  0.17625 0.02161050
## 78  0.17750 0.02188988
## 79  0.17625 0.02079162
## 80  0.17625 0.02079162
## 81  0.39375 0.04007372
## 82  0.18625 0.02853482
## 83  0.18250 0.03238227
## 84  0.17875 0.03230175
## 85  0.17625 0.02531057
## 86  0.16625 0.02433134
## 87  0.16875 0.02301117
## 88  0.16750 0.02776389
## 89  0.17000 0.02513851
## 90  0.16750 0.02220485
## 91  0.17125 0.02128673
## 92  0.17125 0.01958777
## 93  0.17250 0.02108185
## 94  0.17375 0.02161050
## 95  0.17375 0.02389938
## 96  0.17625 0.02161050
## 97  0.17625 0.02161050
## 98  0.17750 0.02188988
## 99  0.17625 0.02079162
## 100 0.17625 0.02079162
## 101 0.39375 0.04007372
## 102 0.18625 0.02853482
## 103 0.18250 0.03238227
## 104 0.17875 0.03230175
## 105 0.17625 0.02531057
## 106 0.16625 0.02433134
## 107 0.16875 0.02301117
## 108 0.16750 0.02776389
## 109 0.17000 0.02513851
## 110 0.16750 0.02220485
## 111 0.17125 0.02128673
## 112 0.17125 0.01958777
## 113 0.17250 0.02108185
## 114 0.17375 0.02161050
## 115 0.17375 0.02389938
## 116 0.17625 0.02161050
## 117 0.17625 0.02161050
## 118 0.17750 0.02188988
## 119 0.17625 0.02079162
## 120 0.17625 0.02079162
## 121 0.39375 0.04007372
## 122 0.18625 0.02853482
## 123 0.18250 0.03238227
## 124 0.17875 0.03230175
## 125 0.17625 0.02531057
## 126 0.16625 0.02433134
## 127 0.16875 0.02301117
## 128 0.16750 0.02776389
## 129 0.17000 0.02513851
## 130 0.16750 0.02220485
## 131 0.17125 0.02128673
## 132 0.17125 0.01958777
## 133 0.17250 0.02108185
## 134 0.17375 0.02161050
## 135 0.17375 0.02389938
## 136 0.17625 0.02161050
## 137 0.17625 0.02161050
## 138 0.17750 0.02188988
## 139 0.17625 0.02079162
## 140 0.17625 0.02079162
## 141 0.39375 0.04007372
## 142 0.18625 0.02853482
## 143 0.18250 0.03238227
## 144 0.17875 0.03230175
## 145 0.17625 0.02531057
## 146 0.16625 0.02433134
## 147 0.16875 0.02301117
## 148 0.16750 0.02776389
## 149 0.17000 0.02513851
## 150 0.16750 0.02220485
## 151 0.17125 0.02128673
## 152 0.17125 0.01958777
## 153 0.17250 0.02108185
## 154 0.17375 0.02161050
## 155 0.17375 0.02389938
## 156 0.17625 0.02161050
## 157 0.17625 0.02161050
## 158 0.17750 0.02188988
## 159 0.17625 0.02079162
## 160 0.17625 0.02079162
## 161 0.39375 0.04007372
## 162 0.18625 0.02853482
## 163 0.18250 0.03238227
## 164 0.17875 0.03230175
## 165 0.17625 0.02531057
## 166 0.16625 0.02433134
## 167 0.16875 0.02301117
## 168 0.16750 0.02776389
## 169 0.17000 0.02513851
## 170 0.16750 0.02220485
## 171 0.17125 0.02128673
## 172 0.17125 0.01958777
## 173 0.17250 0.02108185
## 174 0.17375 0.02161050
## 175 0.17375 0.02389938
## 176 0.17625 0.02161050
## 177 0.17625 0.02161050
## 178 0.17750 0.02188988
## 179 0.17625 0.02079162
## 180 0.17625 0.02079162
## 181 0.39375 0.04007372
## 182 0.18625 0.02853482
## 183 0.18250 0.03238227
## 184 0.17875 0.03230175
## 185 0.17625 0.02531057
## 186 0.16625 0.02433134
## 187 0.16875 0.02301117
## 188 0.16750 0.02776389
## 189 0.17000 0.02513851
## 190 0.16750 0.02220485
## 191 0.17125 0.02128673
## 192 0.17125 0.01958777
## 193 0.17250 0.02108185
## 194 0.17375 0.02161050
## 195 0.17375 0.02389938
## 196 0.17625 0.02161050
## 197 0.17625 0.02161050
## 198 0.17750 0.02188988
## 199 0.17625 0.02079162
## 200 0.17625 0.02079162
## 201 0.39375 0.04007372
## 202 0.18625 0.02853482
## 203 0.18250 0.03238227
## 204 0.17875 0.03230175
## 205 0.17625 0.02531057
## 206 0.16625 0.02433134
## 207 0.16875 0.02301117
## 208 0.16750 0.02776389
## 209 0.17000 0.02513851
## 210 0.16750 0.02220485
## 211 0.17125 0.02128673
## 212 0.17125 0.01958777
## 213 0.17250 0.02108185
## 214 0.17375 0.02161050
## 215 0.17375 0.02389938
## 216 0.17625 0.02161050
## 217 0.17625 0.02161050
## 218 0.17750 0.02188988
## 219 0.17625 0.02079162
## 220 0.17625 0.02079162
## 221 0.39375 0.04007372
## 222 0.18625 0.02853482
## 223 0.18250 0.03238227
## 224 0.17875 0.03230175
## 225 0.17625 0.02531057
## 226 0.16625 0.02433134
## 227 0.16875 0.02301117
## 228 0.16750 0.02776389
## 229 0.17000 0.02513851
## 230 0.16750 0.02220485
## 231 0.17125 0.02128673
## 232 0.17125 0.01958777
## 233 0.17250 0.02108185
## 234 0.17375 0.02161050
## 235 0.17375 0.02389938
## 236 0.17625 0.02161050
## 237 0.17625 0.02161050
## 238 0.17750 0.02188988
## 239 0.17625 0.02079162
## 240 0.17625 0.02079162
## 241 0.39375 0.04007372
## 242 0.18625 0.02853482
## 243 0.18250 0.03238227
## 244 0.17875 0.03230175
## 245 0.17625 0.02531057
## 246 0.16625 0.02433134
## 247 0.16875 0.02301117
## 248 0.16750 0.02776389
## 249 0.17000 0.02513851
## 250 0.16750 0.02220485
## 251 0.17125 0.02128673
## 252 0.17125 0.01958777
## 253 0.17250 0.02108185
## 254 0.17375 0.02161050
## 255 0.17375 0.02389938
## 256 0.17625 0.02161050
## 257 0.17625 0.02161050
## 258 0.17750 0.02188988
## 259 0.17625 0.02079162
## 260 0.17625 0.02079162
stopCluster(cl)

We get our best performance of 0.16625 with a cost of 0.51. The range was reduced due to how long it was taking to run the SVM.

train_err = mean(predict(oj_tune_poly$best.model, OJ_train) != OJ_train$Purchase)
test_err = mean(predict(oj_tune_poly$best.model, OJ_test) != OJ_test$Purchase)
paste('Train Error: ', train_err)
## [1] "Train Error:  0.14875"
paste('Test Error: ', test_err)
## [1] "Test Error:  0.177777777777778"

We get a train error of 0.149 and a test error of 0.177 which is exactly the same as our hyper-parameter version of radial.

8h) Overall, which approach seems to give the best results on this data?

Overall, the best approach to getting the lowest Test Error was doing hyper-parameter tuning which lead to the best results except for the linear model, but the original linear model gave similar results. I believe if I adjusted my range (I won’t because they took hours to run) then I would of gotten at least a test error of 0.177 for the hyper-parameter version of linear.