Hello, I am trying to use SVM from e1071 package for doing binary classification and I am having problems in prediction using SVM. I ran a SVM for X~as.factor(X1)+as.factor(X2)+as.factor(X3),data=data1,cross=10. str(data1) gives me data.frame': 5040 obs. of 5 variables: $ X4: int 1 2 3 4 5 6 7 8 9 10 ... $ X : int 0 1 0 1 0 0 1 1 1 1 ... $ X2: int 1 8 15 18 1 14 10 9 8 8 ... $ X3 : int 9 9 13 13 9 1 1 9 9 9 ... $ X1 : num 29105 29105 29105 29105 29105 ... As factors, X has 2 levels 0,1 X1 has 3 levels 29104.91,29526.78,10401.78 X2 has 19 levels and X3 has 24 levels The test data details are as follows: str(test) data.frame': 6267 obs. of 4 variables: $ X4: int 1 2 3 4 5 6 7 8 9 10 ... $ X2 : int 10 1 18 18 18 5 14 8 8 16 ... $ X3: int 25 25 27 33 10 10 17 17 33 6 ... $ X1 : num 29105 29105 29105 29105 29105 .. I want the prediction of X consolidated on the basis of X4 into a separate data frame. The loop that I wrote for this is: len<-nrow(test); prediction<-data.frame(t(rep(NA,2))); names(prediction)<-c("X4","PredictionX"); prediction<-prediction[-1,]; for(j in 1:len) { prediction[j,1]<-test[j,1]; Forecast.List[j,2]<-predict(X,test[j,]); } when I do this I get the following error: Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : contrasts can be applied only to factors with 2 or more levels. However, when I simply say predict(X,test), it works. When in the loop it throws the above error. In the test data, I didn't declare the X1,X2,X3 to be factors. Is it a factor problem? Where am I going wrong here? Also, I want the svm predict function to not omit the NA's and keep the missing value predictions as NA and give the prediction for the rest. In short I do not want the function to omit the missing values from the prediction data frame. How to resolve this? Thanks Divya -- View this message in context: http://r.789695.n4.nabble.com/Help-in-SVM-prediction-tp3810256p3810256.html Sent from the R help mailing list archive at Nabble.com.