It was my understanding that SVMs did not rely upon the initialization of random weights in the way that Neural Networks do, and that therefore, results of running an SVM model would be consistent given identical data.

So why, then, do I get different results for my $best.parameters (gamma and cost) for the following call to e1071 package's tune.svm() every time I run it?

tune_out <- tune.svm(x = X_train, y = as.factor(y_train),  type = "C-classification", kernel = "radial",
                     cost = c(.01, .1, .5, 1, 2.5, 5, 7.5, 10, 20, 50, 100, 500, 1000), gamma = c(0.1,.5, 1,5, 10,20,50,100), scale = FALSE)

My training set is hard-coded and doesn't vary, so I'm at a loss as to what is going on.

FYI- I have set scale to FALSE as my data is already centered and scaled.


1 Answer 1


I know this is an old question, but just in case it's useful: I assume you were getting different results each run because the tune() function creates random splits each time it's run. So if you want reproducible results you should call set.seed() before each run. From the doc (https://cran.r-project.org/web/packages/e1071/e1071.pdf):

Cross-validation randomizes the data set before building the splits which-once created—remain constant during the training process. The splits can be recovered through the train.ind component of the returned object



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.