Question: Support Vector Machines This assignment will build off of the previous ungraded assignment. However, here you will use a radial basis function for your kernel

Support Vector Machines
This assignment will build off of the previous ungraded assignment. However, here you will use a radial basis function for your kernel rather than a linear specification.
To begin, a synthetic data set has been provided below. It is normally distributed with an added offset to create two separate classes.
library(tidymodels)
library(ISLR2)
set.seed(1)
sim_data2<- tibble(
x1= rnorm(200)+ rep(c(2,-2,0), c(100,50,50)),
x2= rnorm(200)+ rep(c(2,-2,0), c(100,50,50)),
y = factor(rep(c(1,2), c(150,50)))
)
sim_data2%>%
ggplot(aes(x1, x2, color = y))+
geom_point()
Now, you will try an SVM using a radial basis function (RBF). RBF should allow you to capture the non-linearity in the data. To create the specification, you should use svm_rbf(). Be sure to pass in classification as the mode and kernlab as the engine. Save your output to svm_rbf_spec.
# YOUR CODE HERE
set.seed(1)
svm_rbf_spec <- svm_rbf()%>%
set_mode("classification")%>%
set_engine("kernlab", scaled = FALSE)
# your code here
Now fit your model using fit().
# your code here
svm_rbf_fit= function(){
fit(svm_rbf_spec, data = sim_data2)
}
Plot your model. What do you notice?
library(kernlab)
# YOUR CODE HERE

Step by Step Solution

There are 3 Steps involved in it

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

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

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!