Hi I am Aadhithya I am trying to write a code to classify microarray data (AML and ALL) using SVM in R my code goes like this : library(e1071) train<-read.table("Z:/Documents/train.txt",header=T); test<-read.table("Z:/Documents/test.txt",header=T); cl <- c(c(rep("ALL",10), rep("AML",10))); model<- svm(train,cl); pred <- predict(model,t(test)); table(pred,t(cl)); But I am not able to run it its giving me error . I will be really grateful if someone can help me.Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/Need-help-for-SVM-code-for-microarray-classification-tp2271652p2271652.html Sent from the R help mailing list archive at Nabble.com.
Steve Lianoglou
2010-Jun-29 03:09 UTC
[R] Need help for SVM code for microarray classification
Hi, On Mon, Jun 28, 2010 at 9:55 PM, Aadhithya <sistaadhi at gmail.com> wrote:> > Hi I am Aadhithya I am trying to write a code to classify microarray data > (AML and ALL) using SVM in R > my code goes like this : > library(e1071) > train<-read.table("Z:/Documents/train.txt",header=T); > test<-read.table("Z:/Documents/test.txt",header=T); > cl <- c(c(rep("ALL",10), rep("AML",10))); > model<- svm(train,cl); > pred <- predict(model,t(test)); > table(pred,t(cl)); > > But I am not able to run it its giving me error . I will be really grateful > if someone can help me.Thanks in advance1. Please give the error that it's giving you 2. Are the number of features/columns in your training and testing matrices the same? Remember that like most other model-building-type functions in R, the rows of the data represent the different observations, and the columns of the data represent the different features/dimensions/predictor-variabls of each observation. -- 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
Following is the error I am getting: Error in svm.default(train, cl) : Need numeric dependent variable for regression. My dataset looks like this in both training and testing: ALL ALL ALL ALL ALL ALL ALL ALL ALL ALL AML AML AML AML AML AML AML AML AML AML 0.9389671 1.0892019 0.24647887 0.57042253 0.10798122 0.58685446 0.0 0.5399061 0.20422535 0.2488263 0.84976524 0.7910798 0.39906102 0.5633803 1.0938967 0.86384976 1.0633802 0.713615 0.5375587 0.07042254 1.7179487 0.0 0.32051283 0.012820513 0.0 0.0 0.2820513 0.98717946 0.26923078 0.07692308 0.0 0.0 0.24358974 0.0 0.0 0.46153846 0.0 0.20512821 0.20512821 0.0 1.4024506 0.20640905 0.10084826 0.09142318 0.037700284 0.07257304 0.1206409 0.14514609 2.0 0.11310085 0.030160226 0.15834118 0.0028275212 1.1630538 0.14137606 0.31479737 0.2544769 0.12629595 0.24222432 0.0028275212 first line Has the class whether it is ALL or AML class and from the next line I have the expression values is this the right way to give the dataset to R for SVM classification? Thanks a lot for immediate reply. I am really grateful. - Aadhithya -- View this message in context: http://r.789695.n4.nabble.com/Need-help-for-SVM-code-for-microarray-classification-tp2271652p2272045.html Sent from the R help mailing list archive at Nabble.com.