Hi, On Wed, Feb 2, 2011 at 1:40 PM, Brian <ctto...@hotmail.com> wrote: > > There are a good few blanks in some variables in the data. There were in the > training set too. Is that a problem?
Well, it looks like it's the root cause of what prompted you to post to R-help ... whether or not it's *really* a problem is another issue, I guess ... > I don't have any na.action in my svm > call either. Makes sense ... the SVM is just skipping these examples and not using them for training. The default setting for na.action is na.omit, which just removes these cases from training. > So na.omit=na.fail causes this error: > Error in na.fail.default(newdata) : missing values in object Bingo. > I tried the matrix. >>SvmPred = predict(Svm, as.matrix(BankTest[,-1])) > 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' > > Also is.matrix fails for BankTest so it isn't actually a matrix. Not sure it > matters though. The prediction is actually working somewhat, but it only > predicts for 2282 cases instead of 2598. We know why now. Please read the help for the predict.svm function: R> ?predict.svm Specifically the documentation for the `na.action` Argument. Perhaps it would be more friendly if predict just returned an NA in these situations, but I guess this is how it works for the time being. Anyway, it looks like this explains why you have a different number of predictions than you have observations in your BankTest. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.