Solved – Is validation set important in SVM regression analysis

libsvmmachine learningrsvm

I am new to machine learning and currently reading a paper about a ANN modelling in which they have divided their dataset into Training , validation and testing set. I have carried out some minor SVM regression studies of my own using R (e1071); in which I have used only Training Set and testing set but no validation test to create model. I have optimized cost and gamma of my SVR model using inbuilt tune() function.

And this is a sample code

library(e1071)
set.seed(3)
data = data.frame(matrix(rnorm(100*5), nrow=100))
train=data[1:70,]
test=data[71:100,]
op=tune(svm,X1 ~ ., data=train,kernel="radial",ranges=list(cost=c(0.001,0.01),gamma=c(0.5,0.1)))
fit = op$best.model
summary(fit)
pred=predict(fit,test)

So is it necessary to use validation set in SVR. if yes how can I programmatically implement validation set in the above code.

Best Answer

Actually, the "tune" function already split the data into training and validation set and performs, automatically, the cross-validation (10 fold) of your data. The default parameter of the "tune" function can be found by typing "?tune.control" in R console.

So, what you did in your code was correct!

Obs.: If you want to use the function svm directly, you should split between training, validation and test set and implement, for example, the cross-validation of the models.