Re: [R] In svm(), how to connect quantitative prediction result to categorical result?

From: Steve Lianoglou <>
Date: Sun, 10 Apr 2011 23:32:00 -0400

Hi Yunfei,

On Fri, Apr 8, 2011 at 8:35 PM, Li, Yunfei <> wrote:
> Hi,
> I am studying using SVM functions of e1071 package to do prediction, and I found during the training data are "factor" type, then svm.predict() can predict data directly by categories; but if response variables are "numerical", the predicted value from svm will be continuous quantitative numbers, then how can I connect these quantitative numbers to categories? (for example:in an example data set, the response variables are numerical and have two categories: 0 and 1, and the predicted value are continuous quantitative numbers from 0 to 1.3, how can I know which of them represent category 0 and which represent 1?)

You have to figure out if you want the svm to do classification or regression.

If I remember correctly, a "vanilla" call to SVM will try to pick one or the other in a "smart way" by looking at the types (and values) of your labels (y vector).

You can be more explicit and tell the SVM what you want by specifying a value for the `type` argument in your original `svm` call.

See ?svm for more info.

I'm not sure if I'm answering your question or not(?). If I didn't understand what you wanted, perhaps you can rephrase your question, or maybe explain how my answer is not what you were after ... otherwise hopefully someone else can provide a better answer.


Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info:

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 11 Apr 2011 - 03:35:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 11 Apr 2011 - 05:30:28 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive