[R] svm regression

2010-02-18 Thread madhu sankar
Hi,

I am trying to use svm  for regression data.

this is how my data looks like:

dataTrain

x  y   z
1  4  6
2  5  4
3  7  5

classTrain

a
2
3
4

dataTest

x y  z
1 7  2
2 8  3

classTest

a
3
4
5


building the model

model-svm(dataTrain,classTrain,type=nu-regression)
pred - predict(model, dataTest)

 pred
   12
3.008842 3.120078

I don't understand what the above value means.i need the results similar to
classTest.

Thanks,
Joji.

[[alternative HTML version deleted]]

__
R-help@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] svm regression

2010-02-18 Thread madhu sankar
Hi,

I am having trouble with svm regression.it is not giving the right results.

example

 model - svm(dataTrain,classTrain,type=eps-regression)
 predict(model, dataTest)
36 37 38 39 40 41
42
-13.838257  -1.475401  10.502739  -3.047656  -8.713697   3.812873
1.741999
43 44 45 46 47 48
49
 -6.034361 -13.469742   7.628642 -22.197060  -3.417444  -8.536890
-11.876133
50
 -5.877457


My dataSet has 50 columns and 19 rows
my classSet has 50 columns and 1 row

My dataTrain has 35(1:35) columns and 19 rows
My classTrain has 35(1:35) columns and 1 row

My dataTest has 15(36:50) columns and 19 rows
My classTest has 15(36:50) columns and 1 row

My results should be as follows:

 [1] -25.70  30.30 -58.50  -1.12   7.62 -16.10 -48.50  21.10  12.60 -43.00
[11] -47.30 -47.90 -38.40 -21.30  22.40

But instead i get the wrong values.can anyone help me with it.

Thanks,
Joji.

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] svm regression

2010-02-18 Thread Uwe Ligges



On 18.02.2010 17:54, madhu sankar wrote:

Hi,

I am trying to use svm  for regression data.

this is how my data looks like:


dataTrain


x  y   z
1  4  6
2  5  4
3  7  5


classTrain


a
2
3
4


dataTest


x y  z
1 7  2
2 8  3


classTest


a
3
4
5


building the model

model-svm(dataTrain,classTrain,type=nu-regression)
pred- predict(model, dataTest)


pred

12
3.008842 3.120078

I don't understand what the above value means.i need the results similar to
classTest.



They are similar, aren't they?
You talk about svm *regression* rather than classification and call your 
object class. which makes me worry you failed to understand some 
basics of the method.


Uwe Ligges





Thanks,
Joji.

[[alternative HTML version deleted]]

__
R-help@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@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.


Re: [R] svm regression

2010-02-18 Thread Uwe Ligges



On 18.02.2010 19:43, madhu sankar wrote:

Hi,

I am having trouble with svm regression.it is not giving the right results.

example


model- svm(dataTrain,classTrain,type=eps-regression)
predict(model, dataTest)

 36 37 38 39 40 41
42
-13.838257  -1.475401  10.502739  -3.047656  -8.713697   3.812873
1.741999
 43 44 45 46 47 48
49
  -6.034361 -13.469742   7.628642 -22.197060  -3.417444  -8.536890
-11.876133
 50
  -5.877457


My dataSet has 50 columns and 19 rows
my classSet has 50 columns and 1 row

My dataTrain has 35(1:35) columns and 19 rows
My classTrain has 35(1:35) columns and 1 row

My dataTest has 15(36:50) columns and 19 rows
My classTest has 15(36:50) columns and 1 row



Same problems as in my last mail:

I fear you are mixing up several things: regression vs. classification, 
rows vs. columns




My results should be as follows:

  [1] -25.70  30.30 -58.50  -1.12   7.62 -16.10 -48.50  21.10  12.60 -43.00
[11] -47.30 -47.90 -38.40 -21.30  22.40


Why do you know?

Uwe Ligges



But instead i get the wrong values.can anyone help me with it.

Thanks,
Joji.

[[alternative HTML version deleted]]

__
R-help@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@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.


Re: [R] svm regression/classification

2009-12-29 Thread Steve Lianoglou
Hi Nancy,

Comments in line:

On Sun, Dec 27, 2009 at 3:34 AM, Nancy Adam nancyada...@hotmail.com wrote:

 Hi everyone,

 Can anyone please tell whether there is a difference between the code for 
 using svm in regression and code for using svm in classification?

 This is my code for regression, should I change it to do classification?:

I'm not sure how to answer your question ... are you asking how you
can explicitly tell the `svm` function to do classification vs.
regression? Or are you asking if classification is better suited for
your problem than regression?

Are you trying to predict a label or some range of real valued
numbers? Can you show us your `y` vector?

-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

__
R-help@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.


Re: [R] svm regression/classification

2009-12-29 Thread Nancy Adam

Hi steve,
Thank you so much for your reply.I’m asking about the difference between two 
cases:1) when I use svm in a regression system and 2) when I use svm in a 
classification system. Is the code of using svm in these two cases the 
same?This is the code for a regression system:
my_svm_model - function(myformula, mydata, mytestdata) 
{
  mymodel - svm(myformula, data=mydata)   
mytest - predict(mymodel, mytestdata)
error - mytest - mytestdata[,1]
-sqrt(mean(error**2))
}Many thanks,
Nancy
 Date: Tue, 29 Dec 2009 10:36:36 -0500
 Subject: Re: [R] svm regression/classification
 From: mailinglist.honey...@gmail.com
 To: nancyada...@hotmail.com
 CC: r-help@r-project.org
 
 Hi Nancy,
 
 Comments in line:
 
 On Sun, Dec 27, 2009 at 3:34 AM, Nancy Adam nancyada...@hotmail.com wrote:
 
  Hi everyone,
 
  Can anyone please tell whether there is a difference between the code for 
  using svm in regression and code for using svm in classification?
 
  This is my code for regression, should I change it to do classification?:
 
 I'm not sure how to answer your question ... are you asking how you
 can explicitly tell the `svm` function to do classification vs.
 regression? Or are you asking if classification is better suited for
 your problem than regression?
 
 Are you trying to predict a label or some range of real valued
 numbers? Can you show us your `y` vector?
 
 -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
  
_
Keep your friends updated—even when you’re not signed in.

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] svm regression/classification

2009-12-29 Thread Steve Lianoglou
Hi Nancy,

2009/12/30 Nancy Adam nancyada...@hotmail.com:
 Hi steve,

 Thank you so much for your reply.

 I’m asking about the difference between two cases:

 1) when I use svm in a regression system and

 2) when I use svm in a classification system.

  Is the code of using svm in these two cases the same?

Getting the `svm` function to perform classification vs. regression
can be controlled by setting its `type` parameter. The help page for
the function ?svm suggests that this is automatically picked depending
on what type of element your y vector is, eg. it defaults to
classification if your `y` is a vector of factors.

That having been said, you can set this parameter explicitly so that
you're sure of what the function is doing, eg:

## classification:
mymodel - svm(myformula, data=mydata, type='C-classification')

## regression
mymodel - svm(myformula, data=mydata, type='eps-regression')

 This is the code for a regression system:

 my_svm_model - function(myformula, mydata, mytestdata)

     {

   mymodel - svm(myformula, data=mydata)

     mytest - predict(mymodel, mytestdata)

     error - mytest - mytestdata[,1]

     -sqrt(mean(error**2))

     }

That's not really code for a regression system -- as I said above,
performing regression vs. classification depends on what type of
vector your `y` labels turns out to be, given your formula (unless you
explicitly set type='something').

It looks like your `my_svm_model` is a function that calculates (the
negative of) the root-mean-squared-error (why negative, btw?). This
performance calculation is appropriate for regression, but not for
classification. For classification you probably want to report the
accuracy of the labels, eg something like:

mytest - predict(mymodel, mytestdata, type='C-classification')
accuracy - sum(mytest == mytestdata[,1]) / length(mytest)

As I said in my earlier email, it's not really appropriate to try,
say, regression and report accuracy like as its defined for
classification.

I'm not sure if I'm answering your question, partly because I'm not
really sure what you're really asking, ie. I'm not sure if you're
confused as to whether or not you should be doing classification or
regression, or do you know which of the two you want to do but you
don't understand how to get `svm` to perform the one you want?

Please clarify the above point if you still need more help.

Hope that helps,
-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

__
R-help@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] svm regression/classification

2009-12-27 Thread Nancy Adam

 
 
Hi everyone,
 
Can anyone please tell whether there is a difference between the code for using 
svm in regression and code for using svm in classification?
 
This is my code for regression, should I change it to do classification?:
 
train - read.table(trainingset.txt,sep=;)
test - read.table(testset.txt,sep=;)
 
 
svmmodelfitness - function(myformula,mydata,mytestdata) 
{
   
 mymodel - svm(myformula,data=mydata) 
 
  mytest - predict(mymodel, mytestdata)
  error - mytest - mytestdata[,1]
  -sqrt(mean(error**2))
}
 
Many thanks,
Nancy 
_


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] SVM regression

2009-12-12 Thread Eleni Christodoulou
Thank you very much!

Eleni


On Fri, Dec 11, 2009 at 7:19 PM, Steve Lianoglou 
mailinglist.honey...@gmail.com wrote:

 Hi Eleni,

 On Dec 11, 2009, at 12:04 PM, Eleni Christodoulou wrote:

  Dear R users,
 
  I am trying to apply SVM regression for a set of microarray data. I am
 using
  the function svm() under the package {e1071}. Can anyone tell me what
  the *residuals
  *value represents? I have some observed values *y_obs* for the parameter
  that I want to estimate and I would expect that *svm$residuals = y_obs -
  svm$fitted.
  *However, this does not happen...Does anyone have any idea on that?

 This actually is what's happening. The $residuals that are reported in the
 model are against your *scaled* y-vector.

 So, with your data:

 R m - svm(x,y)
 R all(scale(y) - predict(m,x) == m$residuals)
 [1] TRUE

 -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/contacthttp://cbio.mskcc.org/%7Elianos/contact



[[alternative HTML version deleted]]

__
R-help@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] SVM regression

2009-12-11 Thread Eleni Christodoulou
Dear R users,

I am trying to apply SVM regression for a set of microarray data. I am using
the function svm() under the package {e1071}. Can anyone tell me what
the *residuals
*value represents? I have some observed values *y_obs* for the parameter
that I want to estimate and I would expect that *svm$residuals = y_obs -
svm$fitted.
*However, this does not happen...Does anyone have any idea on that?

Thanks a lot!
Eleni C.* *

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] SVM regression

2009-12-11 Thread Steve Lianoglou
Hi Eleni,

On Dec 11, 2009, at 12:04 PM, Eleni Christodoulou wrote:

 Dear R users,
 
 I am trying to apply SVM regression for a set of microarray data. I am using
 the function svm() under the package {e1071}. Can anyone tell me what
 the *residuals
 *value represents? I have some observed values *y_obs* for the parameter
 that I want to estimate and I would expect that *svm$residuals = y_obs -
 svm$fitted.
 *However, this does not happen...Does anyone have any idea on that?

This actually is what's happening. The $residuals that are reported in the 
model are against your *scaled* y-vector.

So, with your data:

R m - svm(x,y)
R all(scale(y) - predict(m,x) == m$residuals)
[1] TRUE

-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

__
R-help@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] SVM regression code

2009-02-19 Thread Alex Roy
Dear R user,
I am looking for SVM regression in R. It willl be
helpful for me if some one send me SVM regression code.
Thanks

Alex

[[alternative HTML version deleted]]

__
R-help@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.