Re: [R] cross validation using e1071:SVM

2010-11-24 Thread Neeti

thank you so much for your help. if i am not wrong then createDataPartition
can be used to create stratified random splits of a data set. 

is there other way to do that?

Thank you
-- 
View this message in context: 
http://r.789695.n4.nabble.com/cross-validation-using-e1071-SVM-tp3055335p3057684.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] cross validation using e1071:SVM

2010-11-23 Thread Francial Giscard LIBENGUE
Hi everyone,
Can you help me to plot Gamma(x/h+1) and Beta(x/h+1,(1-x)/h+1)?I want write
x-seq(0,3,0.1)
thank

2010/11/23 Neeti nikkiha...@gmail.com


 Hi everyone

 I am trying to do cross validation (10 fold CV) by using e1071:svm method.
 I
 know that there is an option (“cross”) for cross validation but still I
 wanted to make a function to Generate cross-validation indices  using pls:
 cvsegments method.

 #

 Code (at the end) Is working fine but sometime caret:confusionMatrix gives
 following error:

 stat_result- confusionMatrix(pred_true1,species_test)

 Error in confusionMatrix.default(pred_true1, species_test) :
  The data and reference factors must have the same number of levels

 My data: total number=260
Class = 6

 #
 Sorry if I missed some previous discussion about this problem.

 It would be nice if anyone explain or point out the mistake I am doing in
 this following code.

 Is there another way to do this? As I wanted to check my result based on
 Accuracy and Kappa value generated by caret:confusionMatrix.

 ##
 Code
 #
 x-NULL
 index-cvsegments(nrow(data),10)
 for(i in 1:length(index))
 {
x-matrix(index[i])
testset-data[x[[1]],]
trainset-data[-x[[1]],]

species-as.factor(trainset[,ncol(trainset)])
train1-trainset[,-ncol(trainset)]
train1-train1[,-(1)]

test_t-testset[,-ncol(testset)]
species_test-as.factor(testset[,ncol(testset)])
test_t-test_t[,-(1)]
model_true1 - svm(train1,species)
pred_true1-predict(model_true1,test_t)
stat_result- confusionMatrix(pred_true1,species_test)
stat_true[[i]]-as.matrix(stat_result,what=overall)
kappa_true[i]-stat_true[[i]][2,1]
accuracy_true[i]-stat_true[[i]][1,1]
 }

 --
 View this message in context:
 http://r.789695.n4.nabble.com/cross-validation-using-e1071-SVM-tp3055335p3055335.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.




-- 
Francial Giscard LIBENGUE
Doctorant en Mathématiques Appliquées ;Option : Statistique
Université de Franche-Comté - UFR Sciences et Techniques
Laboratoire de Mathématiques de Besançon – UMR 6623 CNRS
16, route de Gray - 25030 Besançon cedex, France.
Tel. +333.81.66.63.98  ; Fax +33 381 666 623 ; Bureau B 328.

[[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] cross validation using e1071:SVM

2010-11-23 Thread Neeti


@Francial Giscard LIBENGUE  please post your query again so that with
different subject

-- 
View this message in context: 
http://r.789695.n4.nabble.com/cross-validation-using-e1071-SVM-tp3055335p3055831.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] cross validation using e1071:SVM

2010-11-23 Thread Neeti

could anyone help me with my last problem. if the question is not clear
please let me know

thank you  

Hi everyone 
 
 I am trying to do cross validation (10 fold CV) by using e1071:svm method. 
 I 
 know that there is an option (“cross”) for cross validation but still I 
 wanted to make a function to Generate cross-validation indices  using pls: 
 cvsegments method. 
 
 # 

 Code (at the end) Is working fine but sometime caret:confusionMatrix gives
 following error: 

 stat_result- confusionMatrix(pred_true1,species_test) 

 Error in confusionMatrix.default(pred_true1, species_test) : 
  The data and reference factors must have the same number of levels 

 My data: total number=260 
Class = 6 

 # 
 Sorry if I missed some previous discussion about this problem. 

 It would be nice if anyone explain or point out the mistake I am doing in
 this following code. 

 Is there another way to do this? As I wanted to check my result based on
 Accuracy and Kappa value generated by caret:confusionMatrix. 

 ## 
 Code 
 # 
 x-NULL 
 index-cvsegments(nrow(data),10) 
 for(i in 1:length(index)) 
 { 
x-matrix(index[i]) 
testset-data[x[[1]],] 
trainset-data[-x[[1]],] 

species-as.factor(trainset[,ncol(trainset)]) 
train1-trainset[,-ncol(trainset)] 
train1-train1[,-(1)] 

test_t-testset[,-ncol(testset)] 
species_test-as.factor(testset[,ncol(testset)]) 
test_t-test_t[,-(1)] 
model_true1 - svm(train1,species) 
pred_true1-predict(model_true1,test_t) 
stat_result- confusionMatrix(pred_true1,species_test) 
stat_true[[i]]-as.matrix(stat_result,what=overall) 
kappa_true[i]-stat_true[[i]][2,1] 
accuracy_true[i]-stat_true[[i]][1,1] 
 }

-- 
View this message in context: 
http://r.789695.n4.nabble.com/cross-validation-using-e1071-SVM-tp3055335p3055836.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] cross validation using e1071:SVM

2010-11-23 Thread Max Kuhn
Neeti,

I'm pretty sure that the error is related to the confusionMAtrix call,
which is in the caret package, not e1071.

The error message is pretty clear: you need to pas in two factor
objects that have the same levels. You can check by running the
commands:

   str(pred_true1)
   str(species_test)

Also, caret can do the resampling for you instead of you writing the
loop yourself.

Max

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