[R] getting probabilities from SVM
David Meyer
david.meyer at wu-wien.ac.at
Fri Feb 17 14:07:10 CET 2006
> 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 at 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/
More information about the R-help
mailing list