[R] caret package, how can I deal with RFE+SVM wrong message?

Max Kuhn mxkuhn at gmail.com
Tue Mar 23 16:53:21 CET 2010


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

You 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



More information about the R-help mailing list