Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

(a) 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. Make sure to dispose of original mpg value in the end (Auto$mpg = NULL).

(b) Run set.seed(1). Fit a support vector classifier to the data with various values of cost (similar to the lab), 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.

3

(c) Which cost value gave you the misclassification error? Print the confusion matrix for the optimal cost from part (c). Describe the two types of errors your model can make, and which of those two types does it commit more frequently?

(d) Plot the fitted boundary of the optimal support vector classifier for a couple of predictor pairings. Hint: In the lab, we used the plot() function for svm objects only in cases with p = 2. When p > 2, you can use the plot() function to create plots displaying pairs of variables at a time. Essentially, instead of typing

> plot(svmfit, dat)

where svmfit contains your fitted model and dat is a data frame containing your data, you can type > plot(svmfit, dat, x1~x4 )

in order to plot just the first and fourth variables. However, you must replace x1 and x4 with the correct variable names. To find out more, type ?plot.svm.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Introduction to Operations Research

Authors: Frederick S. Hillier, Gerald J. Lieberman

10th edition

978-0072535105, 72535105, 978-1259162985

Students also viewed these Mathematics questions