5

パフォーマンスの尺度として AUC を使用したいのですが、RFE は RMSE、RSquared、Accuracy、Kappa しかサポートしていません。auc などのカスタマイズされたメトリックを使用するにはどうすればよいですか?

4

1 に答える 1

16

summaryFunction()オブジェクト内でカスタムを指定し、trainControl()そこから適切なセクション メトリックを選択する必要がありますsummaryFunction()。キャレットには、AUC と呼ばれる関数も含まれてtwoClassSummary()いるため、自分で書き込む必要さえありません。次に例を示します。

> library(caret)
> iris <- iris[1:100,]
> iris$Species <- as.factor(as.character(iris$Species))
> 
> tc <- trainControl(method="cv",summaryFunction=twoClassSummary,classProb=T)
> train.rf <- train(Species ~ .,data=iris, method="rf", trControl=tc, metric =  "ROC")
> train.rf
100 samples
  4 predictors
  2 classes: 'setosa', 'versicolor' 

No pre-processing
Resampling: Cross-Validation (10 fold) 

Summary of sample sizes: 90, 90, 90, 90, 90, 90, ... 

Resampling results across tuning parameters:

  mtry  ROC  Sens  Spec  ROC SD  Sens SD  Spec SD
  2     1    1     1     0       0        0      
  3     1    1     1     0       0        0      
  4     1    1     1     0       0        0      

ROC was used to select the optimal model using  the largest value.
The final value used for the model was mtry = 2. 

編集:あなたがそれを望んでいることに気付きましたrfe()-同じことが成り立ちますが、同じ方法でrfeFuncsオブジェクトの「要約」要素を編集する必要があります。元:

rfFuncs$summary <- twoClassSummary
rfe(iris[,-5],iris[,5],rfeControl = rfeControl(rfFuncs), s=2:3,metric="ROC")
Recursive feature selection

Outer resampling method: Bootstrap (25 reps) 

Resampling performance over subset size:

 Variables ROC Sens Spec ROCSD SensSD SpecSD Selected
         2   1    1    1     0      0      0        *
         3   1    1    1     0      0      0         
         4   1    1    1     0      0      0         

The top 2 variables (out of 2):
   Petal.Width, Petal.Lengt
于 2013-08-14T21:44:50.237 に答える