1

これは簡単な質問です。私が愚かな方法でこれを行っていないことを確認するためだけです。auc私は mlr の尺度として使用したいと考えています。また、サンプル サイズが小さいため、LOO も使用しています。もちろん、LOO クロス検証スキームでは、テスト サンプルは常に 1 つのインスタンスのみであるため、auc計算することはできません。もちろん、後で予測を見て計算することもできますが、ネストされた交差検証の内部ループでそれを測定値として使用したい場合に問題が発生します。このようなもの (独自の を定義する必要がありますbinaryTask):

require(mlr)    
#for example purposes we will decide which one is better, vanilla LDA or
#vanilla SVM, in the task specified below
bls = list(makeLearner("classif.lda"),makeLearner("classif.svm"))
#modelMultiplexer allows us to search whole parameter spaces between models
#as if the models themselves were parameters
lrn = makeModelMultiplexer(bls)
#to calculate AUC we need some continuous output, so we set 
#predictType to probabilities
lrn = setPredictType(lrn, "prob")
lrn = setId(lrn, "Model Multiplexer")
#here we could pass the parameters to be tested to both SVM and LDA,
#let's not pass anything so we test the vanilla classifiers instead
ps = makeModelMultiplexerParamSet(lrn)
#finally, the resample strategy, Leave-One-Out ("LOO") in our case
rdesc = makeResampleDesc("LOO")
#parameter space search strategy, in our case we only have one parameter:
#the model. So, a simple grid search will do the trick
ctrl = makeTuneControlGrid()
#The inner CV loop where we choose the best model in the validation data
tune = makeTuneWrapper(lrn, rdesc, par.set = ps, control = ctrl, measure = auc, show.info = FALSE) 
#The outer CV loop where we obtain the performace of the selected model 
#in the test data. mlR is a great interface, we could have passed a list 
#of classifiers and tasks here instead and do it all in one go 
#(beware your memory limitation!)
res = benchmark(tune, binaryTask, rdesc, measure = auc)

auc両方のループで、そのように使用することはできません。mlr毎回一意の再サンプルではなく、すべてのテスト サンプルでメジャーを評価するにはどうすればよいでしょうか?

4

1 に答える 1

1

内側のループに別のリサンプリング戦略を使用してから、次を使用できますauc

library(mlr)    

ps = makeParamSet(
  makeNumericLearnerParam(id = "cp", default = 0.01, lower = 0, upper = 1)
)
ctrl = makeTuneControlRandom(maxit = 10)
inner = makeResampleDesc("Subsample")
lrn = makeLearner("classif.rpart", predict.type = "prob")
tune = makeTuneWrapper(lrn, resampling = inner, par.set = ps, control = ctrl, measure = auc)

outer = makeResampleDesc("LOO")
r = resample(tune, bc.task, resampling = outer, extract = getTuneResult, measure = auc)

また、リサンプル結果を取得して、その上で任意のパフォーマンス測定値を計算することもできますperformance(r$pred, auc)

于 2015-10-21T00:12:06.650 に答える