[R] e1071: Cannot predict probabilities

Mikkel Meyer Andersen r at mikl.dk
Tue Feb 23 21:29:36 CET 2010


Hi,

Thanks a lot for making me aware of that SVM-Type. I just thought it
would give a warning or an error if C-classification wasn't used.

The solution in my real case was to make the response variable a
factor, i.e. before I had Y ~ . with Y numeric. If I first converted Y
to a factor, i.e. Y <- factor(Y), then everything went fine.

Thanks!

Cheers, Mikkel.

2010/2/23 Steve Lianoglou <mailinglist.honeypot at gmail.com>:
> Hi,
>
> On Tue, Feb 23, 2010 at 2:43 PM, Mikkel Meyer Andersen <r at mikl.dk> wrote:
>> Dear list.
>>
>> I using the SVM-methods from the e1071, but I can't get the
>> probabilities when predicting.
>>
>> Code:
>> x <- matrix(rbinom(100, 10, 0.3), ncol=2)
>> y <- apply(x, 1, sum)
>> fit <- svm(y ~ x, method = "C-classification", kernel = "radial",
>> probability = TRUE)
>> predict(fit, x, probability=TRUE)
>>
>> Here predict doesn't containing any probabilities (not as attributes
>> either). Does anybody know what I'm doing wrong or if the package
>> contains any bugs?
>
> Look at your "fit" object, specifically the SVM-Type and notice that
> you are actually running eps-regression, even though you try to
> specify classification. So  the type of "probabilities" you're after
> don't really make sense in regression context.
>
> A "better" posed problem definition will give you what you're after. I
> mean, by just running your  example code, my y vector has 10 different
> (unique) labels (yours maybe different do to your random seed, I
> guess) -- but are you really trying to do 10-way classification?
>
> -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
>



More information about the R-help mailing list