I'm using model and predict of library e1071, it seems to be working fine with training and test data, but not with a new data I'm providing. Code:
data2<-read.table('checked.bed')
data3<-read.csv('result_20_02.csv', header = FALSE)
index<-1:nrow(data2)
testindex<-sample(index,trunc(length(index)/3))
testset<-data2[testindex,]
trainset<-data2[-testindex,]
model1<-tune.svm(V3 ~ .,data=trainset,gamma=10^(-6:1),cost=10^(1:3))
bestGamma<-model1$best.parameters[[1]]
bestC<-model1$best.parameters[[2]]
svm.model<-svm(V3 ~ .,data=trainset,method='C-classification', kernel='radial',
cost=bestC,gamma=bestGamma,verbose=TRUE,cross=10)
svm.pred<-predict(svm.model,testset[,-3],decision.values = TRUE)
svm.pred1<-predict(svm.model,data3[,-3],decision.values = TRUE)
svm.pred is working fine, but not svm.pred1. Error:
Error in scale.default(newdata[, object$scaled, drop = FALSE], center = object$x.scale$"scaled:center", : length of 'center' must equal the number of columns of 'x'
I've checked both the tables (data3 and testset) have 5 columns and same type of data