Homework 08: SVMs for Classification

Instructions

For this homework, you should create a new folder in your homework directory. Call it HW8 or something similar that you can keep track of. Download the homework markdown template file Student_HW_template.Rmd from the course webpage, and put a copy in this folder. Rename it something like HW8_YourName.Rmd. This markdown document will be where you will answer each of the questions below.

The Assignment

SVMs: Classification

We’re going to load again the breast cancer classification data set:

patients <- read.csv("breast-cancer.csv") %>% 
  clean_names() %>% 
  mutate(
    class = factor(class),
    bland_chromatin = as.double(bland_chromatin),
    single_epithelial_cell_size = as.double(single_epithelial_cell_size)
  )

Exercise 1. Copy in your code to create a training and test set. Also create a 10 fold CV set.

Exercise 2. Create a recipe to that predicts class by all other variables. Make sure to normalize the data.

Exercise 3. Create a model specifications for nearest_neighbor (with number of neighbors set to tune), svm_poly (tune the cost and degree), and svm_rbf (tune cost and `rbf_sigma). Add these and your recipe to a workflow set.

Exercise 4. Use workflow_map to tune the models. Use autoplot to display the results.

Exercise 5. Pick the best performing model and parameter set. Fit this model and report your test set metrics. Provide at least one plot or chart to analyze the performance of your model.

Exercise 6. Take a look at your knitted document. Make sure that you have a title and your name, that your formatting looks neat and organized, and that your code is running properly.

Submitting HW

When you’ve successfully answered all the questions, knit your document and submit on Canvas.