I am currently doing a problem of classification when the data is not linearly separable and then I have changed the kernel from linear to radial but in this I also have to defined the value of gamma but I am not able to how to decided the value of gamma so it classify the data accurately.

set.seed(1)

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)

train=sample(200,100)

svfit=svm(y~.,data=dat1,kernel=“radial”,gama=1,cost=1)

In this I have taken the value of gamma =1 but I want to know how to decided it.