[R] SVM Prediction and Plot

Steve Lianoglou mailinglist.honeypot at gmail.com
Wed Feb 2 16:06:43 CET 2011


Hi,

On Wed, Feb 2, 2011 at 9:56 AM, Brian <cttobin at hotmail.com> wrote:
>
> Hi
>
> I'm trying to predict using a model I fitted with SVM.
>
> I constructed the model (called Svm) using a training set, and now I want to
> use a test set (called BankTest) for prediction.
>
> The response variable is in the first column of BankTest.
>
>> SvmPred = predict(Svm, BankTest[,-1], probability=TRUE)
>> SvmPredRes = table(Pred = SvmPred, True = BankTest[,1])
>
> I get this error:
> Error in table(Pred = SvmPred, True = BankTest) :  all arguments must have
> the same length
>
>  I checked the length of both BankTest[,1] and SvmPredict.
>> length(SvmPred)
> [1] 2282
>> length(BankTest[,1])
> [1] 2598
>
> How are these two columns not the same size? Surely the prediction should
> try to predict all the values of BankTest[,1]?

What do you get when you type:

R> head(SvmPred)

-- 
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



More information about the R-help mailing list