[R] help on naivebayes function in R

2010-06-30 Thread Aadhithya

Hi, 
I have written a code in R for classifying microarray data using naive
bayes, the code is given below: 
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))); 
cl - factor(cl) 
model - NaiveBayes(train,cl); 
pred-predict(model,test,type = raw); 
table(pred,cl); 
everything is working fine I am able to build the model and predict also but
I am not able to get the confusion matrix using table function.its giving me
the following error when I execute the line table(pred,cl) 
Error in sort.list(unique.default(x), na.last = TRUE) : 
  'x' must be atomic for 'sort.list' 
Have you called 'sort' on a list?
I am not sure where I am going wrong. I want the confusion matrix using
table function but I am not able to get it . Please help me . I will be
really grateful .Thanks in advance. 
-Aadhithya

-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-on-naivebayes-function-in-R-tp2272720p2272720.html
Sent from the R help mailing list archive at Nabble.com.

__
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] how to tabulate the prediction value using table function for naive baiyes in R

2010-06-30 Thread Aadhithya

Hi, 
I have written a code in R for classifying microarray data using naive
bayes, the code is given below: 
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))); 
cl - factor(cl) 
model - naiveBayes(train,cl); 
pred-predict(model,test,type = raw); 
table(pred,cl); 
everything is working fine I am able to build the model and predict also but
I am not able to get the confusion matrix using table function.its giving me
the following error when I execute the line table(pred,cl) 
Error in table(pred,cl):all arguments must have the same length
I am not sure where I am going wrong. I want the confusion matrix using
table function but I am not able to get it . Please help me .Thanks in
advance. 
-Aadhithya 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-tabulate-the-prediction-value-using-table-function-for-naive-baiyes-in-R-tp2272742p2272742.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Need help for SVM code for microarray classification

2010-06-29 Thread Aadhithya

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.7136150.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.00282752121.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.

__
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] Need help for SVM code for microarray classification

2010-06-29 Thread Aadhithya

Hello Steve 
   Thanks for quick responses its really helping me out .Ya I made the
necessary changes you had mentioned. I was not sure of that 'type' argument
where u had told me to set it to SVM . Do you mean I have to give that
argument in this line cl - c(c(rep(ALL,10), rep(AML,10))); and when I
ran the code the following output I had got :
result:
pred  ALL AML
  ALL   7   5
  AML   3   5
Does this mean that 7 samples of ALL from test file has been classified as
ALL and 5 samples of ALL are classified as AML and so on or is there any
other way we can interpret this result .  I am sorry I am troubling you a
lot  but seriously its a very timely help I am really thankful to you.

-Aadhithya
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-for-SVM-code-for-microarray-classification-tp2271652p2272563.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Need help for SVM code for microarray classification

2010-06-29 Thread Aadhithya

Hi Steve
I had done one more thing I had taken the transpose of both my test and
train files as given below:
model- svm(t(train),cl);
pred - predict(model,t(test));
And the result I had got is :
Result:
pred   ALL AML
  ALL   10   0
  AML   0   10

why is there a difference in the result which I had given in the before
post?does this mean doing transpose classifies the samples better? or is
there any reason for this?
Thanks a ton in advance.
-Aadhithya
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-for-SVM-code-for-microarray-classification-tp2271652p2272590.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Need help for SVM code for microarray classification

2010-06-29 Thread Aadhithya

Hello Steve 
   Thanks for quick responses its really helping me out .Ya I made the
necessary changes you had mentioned. I was not sure of that 'type' argument
where u had told me to set it to SVM . Do you mean I have to give that
argument in this line cl - c(c(rep(ALL,10), rep(AML,10))); and when I
ran the code the following output I had got : 
result: 
pred  ALL AML 
  ALL   7   5 
  AML   3   5
Does this mean that 7 samples of ALL from test file has been classified as
ALL and 5 samples of ALL are classified as AML and so on or is there any
other way we can interpret this result . I had done one more thing I had
taken the transpose of both my test and train files as given below: 
model- svm(t(train),cl); 
pred - predict(model,t(test)); 
And the result I had got is : 
Result: 
pred   ALL     AML 
  ALL   10       0 
  AML   0       10 

why is there a difference in the result which I had given in the before
post?does this mean doing transpose classifies the samples better? or is
there any reason for this? 
I am sorry I am troubling you a lot  but seriously its a very timely help I
am really thankful to you. 

-Aadhithya
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-for-SVM-code-for-microarray-classification-tp2271652p2272658.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Need help for SVM code for microarray classification

2010-06-28 Thread Aadhithya

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.

__
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.