libsvm - SVM in R library e1071 error in predict function -
i'm using model , predict of library e1071, seems working fine training , test data, not 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 working fine, not svm.pred1. error:
error in scale.default(newdata[, object$scaled, drop = false], center = object$x.scale$"scaled:center", : length of 'center' must equal number of columns of 'x'
i've checked both tables (data3 , testset) have 5 columns , same type of data
Comments
Post a Comment