Fabon Dzogang
2011-May-05 22:43 UTC
[R] [caret package] [trainControl] supplying predefined partitions to train with cross validation
Hi all, I run R 2.11.1 under ubuntu 10.10 and caret version 2.88. I use the caret package to compare different models on a dataset. In order to compare their different performances I would like to use the same data partitions for every models. I understand that using a LGOCV or a boot type re-sampling method along with the "index" argument of the trainControl function, one is able to supply a training partition to the train function. However, I would like to apply a 10-fold cross validation to validate the models and I did not find any way to supply some predefined partition (created with createFolds) in this setting. Any help ? Thank you and great package by the way ! Fabon Dzogang.
neetika nath
2011-May-06 08:59 UTC
[R] [caret package] [trainControl] supplying predefined partitions to train with cross validation
Hi, I did the similar experiment with my data. may be following code will give you some idea. It might not be the best solution but for me it worked. please do share if you get other idea. Thank you #### CODE### library(dismo) set.seed(111) dd<-read.delim("yourfile.csv",sep=",",header=T) # To keep a check on error options(error=utils::recover) # dd- data to be split for 10 Fold CV, this will split complete data into 10 fold number<-kfold(dd, k=10) case 1: if k ==1 x<-NULL; #retrieve all the index (from your data) for 1st fold in x, such that you can use it as a test set and remaining can be used as train set for #1stiteration. x<-which(number==k) On Thu, May 5, 2011 at 11:43 PM, Fabon Dzogang <fabon.dzogang@lip6.fr>wrote:> Hi all, > > I run R 2.11.1 under ubuntu 10.10 and caret version 2.88. > > I use the caret package to compare different models on a dataset. In > order to compare their different performances I would like to use the > same data partitions for every models. I understand that using a LGOCV > or a boot type re-sampling method along with the "index" argument of > the trainControl function, one is able to supply a training partition > to the train function. > > However, I would like to apply a 10-fold cross validation to validate > the models and I did not find any way to supply some predefined > partition (created with createFolds) in this setting. Any help ? > > Thank you and great package by the way ! > > Fabon Dzogang. > > ______________________________________________ > 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. >[[alternative HTML version deleted]]
Apparently Analagous Threads
- [klaR package] [NaiveBayes] warning message numerical 0 probability
- CARET. Relationship between data splitting trainControl
- Caret: Use timingSamps leads to error
- caret train and trainControl
- caret package: custom summary function in trainControl doesn't work with oob?