[R] probabilities in svm output in e1071 package

Steve Lianoglou mailinglist.honeypot at gmail.com
Thu May 6 03:07:43 CEST 2010


Hi Changbin,

On Wed, May 5, 2010 at 6:46 PM, Changbin Du <changbind at gmail.com> wrote:
> svm.fit<-svm(as.factor(out) ~ ., data=all_h, method="C-classification",
> kernel="radial", cost=bestc, gamma=bestg, cross=10) # model fitting
>
> svm.pred<-predict(svm.fit, hh, decision.values = TRUE, probability = TRUE) #
> find the probability, but can not find.
>
> attr(svm.pred, "probabilities")
>
>> attr(svm.pred, "probabilities")
>     1 0
> 1    0 0
> 2    0 0
> 3    0 0
> 5    0 0
> 6    0 0
> 7    0 0
> 8    0 0
> 9    0 0
>
> Hi, Dear R community,
>
> IN my data, the out variable is the target variable (0, and 1),   hh is the
> new data set does not contain the out variable. I trained the model svm.fit
> in training data. And want to predict the out in the new data set hh.
>
> WHy the probabilities are both 0 in 1 and 0 class?

Look at the help for the svm function:

?svm

Notice that there is a parameter in the svm function call named
`probability` with a default value of FALSE. Try:

svm.fit<-svm(as.factor(out) ~ ., data=all_h, method="C-classification",
kernel="radial", cost=bestc, gamma=bestg, cross=10, probability=TRUE)

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