Re: [R] getting probabilities from SVM

From: David Meyer <david.meyer_at_wu-wien.ac.at>
Date: Sat 18 Feb 2006 - 00:07:10 EST


> Finally figured it out. You have to extract it from the attributes.
> Tricky. Thanks anyway.

> attr(pred, "prob")[1:10,]

Correct.

Just for the records, the rationale behind this `tricky' design:

In addition to probabilites, predict.svm() (more precisely: libsvm) can also compute the decision values. Common ways to handle `polymorph' prediction types are, e.g, using a `type' argument in the predict() function, or to return all variants in one list object. With a `type' argument, you need several calls to predict() if you need, say, hard predictions _and_ the probabilities. On the other hand, the probability and decision values features were added to libsvm only when svm() in e1071 had already been around for a while, so returning a list instead of a vector would have broken a lot of code. So I decided to keep the `standard' predict behavior and to `hide' special predictions in an attribute. If the latter had been available from the beginning, I probably would have used the `type' approach.

Cheers,
David

On 2/16/06, roger bos <roger.bos@gmail.com> wrote:
>
> I am using SVM to classify categorical data and I would like the
> probabilities instead of the classification. ?predict.svm says that its
> only enabled when you train the model with it enabled, so I did that, but it
> didn't work. I can't even get it to work with iris. The help file shows
> that probability = TRUE when training the model, but doesn't show an
> example. Then I try to predict with probabilities, I still only get
> classifications back. Anyone get this to work and can help me out?

-- 
Dr. David Meyer
Department of Information Systems and Operations

Vienna University of Economics and Business Administration
Augasse 2-6, A-1090 Wien, Austria, Europe
Fax: +43-1-313 36x746 
Tel: +43-1-313 36x4393
HP:  http://wi.wu-wien.ac.at/~meyer/

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Feb 18 00:24:14 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:34 EST