Quantcast

svm

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: svm

Steve Lianoglou-6
Hi Amy,

On Sat, Feb 20, 2010 at 9:29 PM, Amy Hessen <[hidden email]> wrote:

> Hi ,
>
> Could you please help me in this question:?
>
> After trying this code:
>
> library(e1071)
>  mydata <- as.matrix(read.delim("iris.txt"))
>  train.x <- mydata[,-1]
>  train.y <- mydata[,1]
>  mymodel <- svm(train.x, train.y, cross=3, type="C-classification")
>
> I receive this error:
>
> Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric
>
> I put the class label in the first column.

I think you would be able to find out where many of your problems lie
if you try to provide a reproducible example we can use to test:
meaning, something I can just copy from your email and paste into my R
workspace that would reproduce your problem.

The error is telling you that something is expecting "x" to be
numeric, and it's not. So the question is, what isn't "numeric"? I
guess the answer must be in one of the two arguments you supply to the
svm function, so can you please check to see what "type" of arguments
you are passing into your function?

You can do that by running these R commands?

R> is(mydata)
R> is(train.x)
R> is(train.y)

What do you get from that?

-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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: svm

Amy Hessen

Hi Steve,
Thank you so much for your reply.
 
I’m attaching the dataset and this is my code:
 
library(e1071)
mydata <- as.matrix(read.delim("iris.txt"))
train.x <- mydata[,-1]
train.y <- mydata[,1]
 mymodel <- svm(train.x, train.y, cross=3, type="C-classification")
 
Could you please try it and try it with the attached dataset? I tried it with different datasets and the problem remains.
Cheers,
Amy

 

> Date: Mon, 22 Feb 2010 10:02:31 -0500
> Subject: Re: [R] svm
> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]
>
> Hi Amy,
>
> On Sat, Feb 20, 2010 at 9:29 PM, Amy Hessen <[hidden email]> wrote:
> > Hi ,
> >
> > Could you please help me in this question:?
> >
> > After trying this code:
> >
> > library(e1071)
> >  mydata <- as.matrix(read.delim("iris.txt"))
> >  train.x <- mydata[,-1]
> >  train.y <- mydata[,1]
> >  mymodel <- svm(train.x, train.y, cross=3, type="C-classification")
> >
> > I receive this error:
> >
> > Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric
> >
> > I put the class label in the first column.
>
> I think you would be able to find out where many of your problems lie
> if you try to provide a reproducible example we can use to test:
> meaning, something I can just copy from your email and paste into my R
> workspace that would reproduce your problem.
>
> The error is telling you that something is expecting "x" to be
> numeric, and it's not. So the question is, what isn't "numeric"? I
> guess the answer must be in one of the two arguments you supply to the
> svm function, so can you please check to see what "type" of arguments
> you are passing into your function?
>
> You can do that by running these R commands?
>
> R> is(mydata)
> R> is(train.x)
> R> is(train.y)
>
> What do you get from that?
>
> -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
     
_________________________________________________________________
View photos of singles in your area! Browse profiles for FREE


______________________________________________
[hidden email] 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.

iris.txt (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: svm

Amy Hessen
In reply to this post by Steve Lianoglou-6


Hi Steve,
Could you please tell me what I should change in this equation: “accuracy <- sum(mytest == mytestdata[,1]) / length(mytest)”In order to compute the accuracy of SVM when using cross validation?Cheers,Amy    
_________________________________________________________________


        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.
12
Loading...