bbslover
2010-Mar-23 08:42 UTC
[R] caret package, how can I deal with RFE+SVM wrong message?
Hello, I am learning caret package, and I want to use the RFE to reduce the feature. I want to use RFE coupled Random Forest (RFE+FR) to complete this task. As we know, there are a number of pre-defined sets of functions, like random Forest(rfFuncs), however,I want to tune the parameters (mtr) when RFE, and then I write code below, but there is something wrong message, How can I deal with it?> rfGrid<-expand.grid(.mtry=c(1:2)) > rfectrl<-rfeControl(functions=caretFuncs,method="cv",verbose=F,returnResamp="final",number=10) > subsets<-c(3,4) > set.seed(2) > rf.RFE<-rfe(trx,try,sizes=subsets,rfeControl=rfectrl,method="rf",tuneGrid=rfGrid)Loading required package: class Attaching package: 'class' The following object(s) are masked from package:reshape : condense Fitting: mtry=1 Fitting: mtry=2 Error in varImp.randomForest(object$finalModel, ...) : subscript out of bounds In addition: Warning message: package 'e1071' was built under R version 2.10.1 At the same time, If I want to use RFE+SVM, RFE+nnet, and so on ,how can I do? I have try RFE+SVM, also wrong message:> set.seed(1)> svmProfile<-rfe(trx,try,sizes=c(1:3),+ rfeControl=rfeControl(functions=caretFuncs,method="cv", + verbose=F,returnResamp="final",number=10), + method="svmRadial",tuneLength=5) Fitting: sigma=0.009246713, C=0.1 Fitting: sigma=0.009246713, C=1 Fitting: sigma=0.009246713, C=10 Fitting: sigma=0.009246713, C=100 Fitting: sigma=0.009246713, C=1000 Error in rfeControl$functions$rank(fitObject, .x, y) : need importance columns for each class thank you! -- View this message in context: http://n4.nabble.com/caret-package-how-can-I-deal-with-RFE-SVM-wrong-message-tp1678800p1678800.html Sent from the R help mailing list archive at Nabble.com.
Max Kuhn
2010-Mar-23 15:53 UTC
[R] caret package, how can I deal with RFE+SVM wrong message?
Kevin! I've sent 5 replies to your questions already off-list. The first question is easy (see below). The others will need more information on your data (via str(trx) abd str(try)) and you versions (sessionInfo()) as previously asked off-list. Sorry to out you, but this is bad form. Max> I am learning caret package, and I want to use the RFE to reduce the > feature. I want to use RFE coupled Random Forest (RFE+FR) to complete this > task. As we know, there are a number of pre-defined sets of functions, like > random Forest(rfFuncs), however,I want to tune the parameters (mtr) when > RFE, and then I write code below, but there is something wrong message, How > can I deal with it? >> rfGrid<-expand.grid(.mtry=c(1:2)) >> rfectrl<-rfeControl(functions=caretFuncs,method="cv",verbose=F,returnResamp="final",number=10) >> subsets<-c(3,4) >> set.seed(2) >> rf.RFE<-rfe(trx,try,sizes=subsets,rfeControl=rfectrl,method="rf",tuneGrid=rfGrid) > Loading required package: class > > Attaching package: 'class' > > > ? ? ? ?The following object(s) are masked from package:reshape : > > ? ? ? ? condense > > Fitting: mtry=1 > Fitting: mtry=2 > Error in varImp.randomForest(object$finalModel, ...) : > ?subscript out of bounds > In addition: Warning message: > package 'e1071' was built under R version 2.10.1You didn't pass importance = TRUE to randomForest> At the same time, If I want to ?use RFE+SVM, ?RFE+nnet, and so on ,how can I > do? I have try RFE+SVM, also wrong message:> set.seed(1) >> svmProfile<-rfe(trx,try,sizes=c(1:3), > + ? ? ? ? ? ? rfeControl=rfeControl(functions=caretFuncs,method="cv", > + ? ? ? ? ? ? verbose=F,returnResamp="final",number=10), > + ? ? ? ? ? ? method="svmRadial",tuneLength=5) > Fitting: sigma=0.009246713, C=0.1 > Fitting: sigma=0.009246713, C=1 > Fitting: sigma=0.009246713, C=10 > Fitting: sigma=0.009246713, C=100 > Fitting: sigma=0.009246713, C=1000 > Error in rfeControl$functions$rank(fitObject, .x, y) : > ?need importance columns for each class-- Max
Apparently Analagous Threads
- Please help me!!!! Error in `[.data.frame`(x, , retained, drop = FALSE) : undefined columns selected
- R-help ordinal regression
- Dummy variables using rfe in caret for variable selection
- Re: starting a domain only when you have enough resources
- CARET and NNET fail to train a model when the input is high dimensional