Instruction

Please remove this section when submitting your homework.

Students are encouraged to work together on homework and/or utilize advanced AI tools. However, there are two basic rules:

Final submissions must be uploaded to Gradescope. No email or hard copy will be accepted. Please refer to the course website for late submission policy and grading rubrics.

Question 1 [40 pts]: Linear SVM and support vectors

We will use the Social Network Ads data, available on Kaggle [link]. The .csv file is also available at our course website. The goal is to classify the outcome Purchased, and we will only use the two continuous variables EstimatedSalary and Age. Scale and center both covariates before you proceed with these following steps. For this question, you should use the e1071 package. Complete the following tasks:

Question 2 [30 pts]: Nonlinear SVM

In this question, we will use the same training and testing data from the previous question. Complete the following tasks. For this question, you can use the predict() function to make predictions.

Question 3 [30 pts]: SVM for hand written digit Data

Take digits 4 and 9 from zip.train and zip.test in the ElemStatLearn package. For this question, you should use the kernlab package, in combination with the caret package to tune the parameters. Make sure that you specify the method = argument so that the correct package/function is used to fit the model. You may consider reading the details from this documentation. Complete the following task.