[R] svm.formula versus svm.default - different results

Cristina Pascual crosspide at hotmail.com
Thu Jul 6 16:12:21 CEST 2017


Dear community,


I'm performing svm-regression  with svm at library e1071.


As I wrote in another post: "svm e1071 call - different results", I get different results if I use the svm.default rather than the svm.formula, being better the ones at svm.formula


I've debugged both options.


While debugging the svm.formula, I've seen that when I reach the call:


ret <- svm.default(x,y, scale= scale, ..., na.action= na.action)


x arrives with the response included, as if svm.formula had not understood which is the response, and hadn't removed it from the overall data.


It doesn't happen if I debug the iris example at R documentation, maybe it is because this Iris one is a classification problem.


¿am i writing properly the S3 object for svm.formula?

This is what I'm trying:

TYPE1

mod = svm(train[, 8] ~ . , data= train)
pred.svm <- predict (mod, train)
error.svm <-  train$revenues - pred.svm
pred.svm.test <- predict (mod, test)
svmPredictionRMSE <- rmse(error.svm)
0.05239259
error.svm.test <-  test$revenues - pred.svm.test
svmPredictionRMSE.test <- rmse(error.svm.test)
0.06932511

TYPE2

mod.1 = svm(train[, -8] , train[, 8])
pred.1.svm <- predict (mod.1, train[, -8])
error.1.svm <-  train$revenues - pred.1.svm
rmse(error.1.svm)
0.3695311
pred.1.svm.test <- predict (mod.1, test[, -8])
error.1.svm.test <-  test$revenues - pred.1.svm.test
rmse(error.1.svm.test)
0.412292

Find attached my data.

train.txt<http://r.789695.n4.nabble.com/file/n4740595/train.txt>

test.txt<http://r.789695.n4.nabble.com/file/n4740595/test.txt>


And rmse:

function(error)
{
         sqrt(mean(error^2, na.rm= TRUE))
}

Thanks in advance,

	[[alternative HTML version deleted]]



More information about the R-help mailing list