Re: [R] Questions bout SVM

2010-01-03 Thread Steve Lianoglou
2010/1/2 Nancy Adam nancyada...@hotmail.com:
 Hi Steve,

 Thanks a lot for your reply.

 1)I’m still confused which equation (1- sqrt(mean(mymodel$MSE)) OR 2-
 mean(sqrt(mymodel$MSE)) )is equivalent to sqrt(mean(error**2))?

So, as I mentioned before, mymodel$MSE is a vector that's as long as
the number of folds your are using for cross validation. If you're
setting cross=10, $MSE will have 10 values in it. Each value is the
*mean squared error* for each fold (as described in the ?svm
documentation under the `cross` parameter).

If you do 1: sqrt(mean(mymodel$MSE)), then you're taking the square
root of the averaged mean squared error.

If you do 2: mean(sqrt(mymodel$MSE)), you are taking the average of
the square root of the MSE from each fold.

 I just want to compute the typical RMSE that is usually used for measuring
 the performance of regression systems.

It sounds like you want to do 2.

 2)I’m talking about another addition related to the svm parameters in the
 call to SVM. i.e.

 my_svm_model- function(myformula, mydata, mytestdata, parameterlist) {

 mymodel - svm(myformula, data=mydata, cross=10, cost=parameterlist[[1]],
 epsilon=parameterlist[[2]],gamma=parameterlist[[3]])

 If I don’t set these parameters of svm (like: my_svm_model-
 function(myformula, mydata, mytestdata), how does svm know them?

Functions can define default values for their arguments. So if you
don't define their values when you call the function, they will take
their defaults. For example, if you don't explicitly set things like
the `cost` (for c-classification), or `epsilon` for regression, etc.
it will take the default values.

You can see the default value for these params in the documentation for ?svm

 3) in 2) Is it correct to use “mydata” instead of “data=mydata”? Or I can do
 that only if it is the “last” argument in the function call?

It's not because it's the last argument, but because it's the second
argument. `data` is defined as the second argument of the `svm`
function (when used with a formula), and you are passing it as the 2nd
argument when you call the function.

 4)Does mytestdata[,1] means that the model will use only the last column on
 the testing set?

mytestdata[,1] means you are taking the first column of the mytestdata
matrix and treating it as a vector and ignoring the rest of the matrix
...

From some previous correspondence, and questions 2 and 3 from here,
honestly I'd suggest investing some time in brushing up on R basics.
Reading the R intro is as good a place to start as any:

http://cran.r-project.org/doc/manuals/R-intro.html

There are several sections on indexing vectors, matrices, etc. Section
10 of that document also talks a bit about named, positional, and
default arguments ...

HTH,
-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] Questions bout SVM

2010-01-02 Thread Steve Lianoglou
Hi,

On Fri, Jan 1, 2010 at 1:03 PM, Nancy Adam nancyada...@hotmail.com wrote:

 Hi everyone,
 Can someone please help me in these questions?:

 1)if I use crossvalidation with svm, do I have to use this equation to 
 calculate RMSE?:
      mymodel - svm(myformula,data=mydata,cross=10)
      sqrt(mean(mymodel$MSE))

No, I don't think so. W/o looking at the C code, I'm guessing that MSE
is a vector of length 10 that represents the mean squared error from
each fold ... but what are you trying to do? Trying to get the average
of the RMSE over all folds? Wouldn't that then be:
mean(sqrt(mymodel$MSE))?

 But if I don’t use crossvalidation, I have to use the following to calculate 
 RMSE:
      mymodel - svm(myformula,data=mydata)
      mytest - predict(mymodel, mytestdata)
      error - mytest - mytestdata[,1]
      sqrt(mean(error**2))

OK

 2)if I don’t set the parameters of SVM, like in the above, how the program 
 knows them? Or it is a must to determine them when I invoke svm?

What parameters are you talking about? Your two `svm` function calls
look the same with the exception of not including a value for `cross`
in your 2nd.

What parameters of the SVM do you think are different?

 3)can you please tell me why we use this equation:
 mymodel - svm(myformula,data=mydata)instead of mymodel - svm(myformula, 
 mydata)

Since the data argument is the 2nd argument in the function
definition of svm.formula, those two invocations are actually the
same.

 and why use this:
 error - mytest - mytestdata[,1] instead of error - mytest – mytestdata

It depends on what type of variable 'mytestdata' is, and its shape,
eg. those two calls might be doing the same thing if mytestdata is
just a 1d matrix.

-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] Questions bout SVM

2010-01-02 Thread Nancy Adam

Hi Steve, Thanks a lot for your reply.1)I’m still confused which equation (1- 
sqrt(mean(mymodel$MSE)) OR 2- mean(sqrt(mymodel$MSE)) )is equivalent to 
sqrt(mean(error**2))?I just want to compute the typical RMSE that is usually 
used for measuring the performance of regression systems. 2)I’m talking about 
another addition related to the svm parameters in the call to SVM. 
i.e.my_svm_model- function(myformula, mydata, mytestdata, parameterlist) 
{mymodel - svm(myformula, data=mydata, cross=10, cost=parameterlist[[1]], 
epsilon=parameterlist[[2]],gamma=parameterlist[[3]])If I don’t set these 
parameters of svm (like: my_svm_model- function(myformula, mydata, 
mytestdata), how does svm know them? 3) in 2) Is it correct to use “mydata” 
instead of “data=mydata”? Or I can do that only if it is the “last” argument in 
the function call? 4)Does mytestdata[,1] means that the model will use only the 
last column on the testing set?Many thanks,Nancy 

 
 Date: Sat, 2 Jan 2010 17:32:44 -0500
 Subject: Re: [R] Questions bout SVM
 From: mailinglist.honey...@gmail.com
 To: nancyada...@hotmail.com
 CC: r-help@r-project.org
 
 Hi,
 
 On Fri, Jan 1, 2010 at 1:03 PM, Nancy Adam nancyada...@hotmail.com wrote:
 
  Hi everyone,
  Can someone please help me in these questions?:
 
  1)if I use crossvalidation with svm, do I have to use this equation to 
  calculate RMSE?:
   mymodel - svm(myformula,data=mydata,cross=10)
   sqrt(mean(mymodel$MSE))
 
 No, I don't think so. W/o looking at the C code, I'm guessing that MSE
 is a vector of length 10 that represents the mean squared error from
 each fold ... but what are you trying to do? Trying to get the average
 of the RMSE over all folds? Wouldn't that then be:
 mean(sqrt(mymodel$MSE))?
 
  But if I don’t use crossvalidation, I have to use the following to 
  calculate RMSE:
   mymodel - svm(myformula,data=mydata)
   mytest - predict(mymodel, mytestdata)
   error - mytest - mytestdata[,1]
   sqrt(mean(error**2))
 
 OK
 
  2)if I don’t set the parameters of SVM, like in the above, how the program 
  knows them? Or it is a must to determine them when I invoke svm?
 
 What parameters are you talking about? Your two `svm` function calls
 look the same with the exception of not including a value for `cross`
 in your 2nd.
 
 What parameters of the SVM do you think are different?
 
  3)can you please tell me why we use this equation:
  mymodel - svm(myformula,data=mydata)instead of mymodel - svm(myformula, 
  mydata)
 
 Since the data argument is the 2nd argument in the function
 definition of svm.formula, those two invocations are actually the
 same.
 
  and why use this:
  error - mytest - mytestdata[,1] instead of error - mytest – mytestdata
 
 It depends on what type of variable 'mytestdata' is, and its shape,
 eg. those two calls might be doing the same thing if mytestdata is
 just a 1d matrix.
 
 -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.


[R] Questions bout SVM

2010-01-01 Thread Nancy Adam

Hi everyone,
Can someone please help me in these questions?:
 
1)if I use crossvalidation with svm, do I have to use this equation to 
calculate RMSE?:
  mymodel - svm(myformula,data=mydata,cross=10)
  sqrt(mean(mymodel$MSE)) 
But if I don’t use crossvalidation, I have to use the following to calculate 
RMSE:
  mymodel - svm(myformula,data=mydata)   
  mytest - predict(mymodel, mytestdata)
  error - mytest - mytestdata[,1]
  sqrt(mean(error**2))
2)if I don’t set the parameters of SVM, like in the above, how the program 
knows them? Or it is a must to determine them when I invoke svm?
 
3)can you please tell me why we use this equation:
mymodel - svm(myformula,data=mydata)instead of mymodel - svm(myformula, 
mydata)   
 
and why use this:
error - mytest - mytestdata[,1] instead of error - mytest – mytestdata
 
any help will be really appricaited.
Many thanks,
Nancy 
_
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.