Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Students also viewed these Databases questions

Question

Identify cultural barriers to communication.

Answered: 1 week ago