Li, Yunfei
2011-Apr-09 00:35 UTC
[R] In svm(), how to connect quantitative prediction result to categorical result?
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?) Best, Yunfei Li -------------------------------------------------------------------------------------- Research Assistant Department of Statistics & School of Molecular Biosciences Biotechnology Life Sciences Building 427 Washington State University Pullman, WA 99164-7520 Phone: 509-339-5096 http://www.wsu.edu/~ye_lab/people.html [[alternative HTML version deleted]]
Steve Lianoglou
2011-Apr-11 03:32 UTC
[R] In svm(), how to connect quantitative prediction result to categorical result?
Hi Yunfei, On Fri, Apr 8, 2011 at 8:35 PM, Li, Yunfei <yunfei_li at wsu.edu> 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 -- 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
Saeed Abu Nimeh
2011-Apr-12 14:54 UTC
[R] In svm(), how to connect quantitative prediction result to categorical result?
I trained a linear svm and did classification. looking at the model I have, with a binary response 0/1, the decision values look like this: head(svm.model$decision.values) 2.5 3.1 -1.0 looking at the fitted values head(svm.model$fitted) 1 1 0 So it looks like anything less than or equal 0 is mapped to the negative class, i.e. 0), otherwise it is mapped to the positive class, i.e. 1. On Fri, Apr 8, 2011 at 8:35 PM, Li, Yunfei <yunfei_li at wsu.edu> 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?) > > Best, > > Yunfei Li > -------------------------------------------------------------------------------------- > Research Assistant > Department of Statistics & > School of Molecular Biosciences > Biotechnology Life Sciences Building 427 > Washington State University > Pullman, WA 99164-7520 > Phone: 509-339-5096 > http://www.wsu.edu/~ye_lab/people.html > > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Steve Lianoglou
2011-Apr-12 15:55 UTC
[R] In svm(), how to connect quantitative prediction result to categorical result?
Hi, On Tue, Apr 12, 2011 at 10:54 AM, Saeed Abu Nimeh <sabunime at gmail.com> wrote:> I trained a linear svm and did classification. looking at the model I > have, with a binary response 0/1, the decision values look like this: > head(svm.model$decision.values) > 2.5 > 3.1 > -1.0 > > looking at the fitted values > head(svm.model$fitted) > 1 > 1 > 0 > So it looks like anything less than or equal 0 is mapped to the > negative class, i.e. 0), otherwise it is mapped to the positive class, > i.e. 1.Yes -- so far, so good. In SVM classification, when examples are predicted with a positive decision value they are assigned to one class (lets say +1), and examples with negative decision value are assigned to the other (-1). Was there a remaining question, or? -steve> > > > On Fri, Apr 8, 2011 at 8:35 PM, Li, Yunfei <yunfei_li at wsu.edu> 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?) >> >> Best, >> >> Yunfei Li >> -------------------------------------------------------------------------------------- >> Research Assistant >> Department of Statistics & >> School of Molecular Biosciences >> Biotechnology Life Sciences Building 427 >> Washington State University >> Pullman, WA 99164-7520 >> Phone: 509-339-5096 >> http://www.wsu.edu/~ye_lab/people.html >> >> >> ? ? ? ?[[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- 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