How to classify the data in SVM when the data is not linearly separable

svm
r

#1

I am currently studying about SVM in R and I have created the model of separation when the data is linear separable but when I have tried this model on data which does not look like linearly separable I am not getting good result I want to know how to use SVM when data is not linear separable.

x<-matrix(rnorm(400),ncol=2)
x[1:100,]=x[1:100,]+2
x[100:150,]=x[100:150,]-2
y<-c(rep(1,150),rep(2,50))
dat1<-data.frame(x,as.factor(y))
plot(x,col=y)

Here we can see that data can not be separated by linear line.


#2

@hinduja1234-you can change the value of kernel to radial or polynomial which helps in classification when data is not linearly classified like the above data.

Hope this helps!
Regards,
harry