I am doing nested cross-validation using the packages mlr and mlrMBO. The inner CV is used for parametrization (e.g. to find the optimal parameters). Since I want to compare the performance of different learners, I conduct a benchmark experiment using mlr's benchmark function. My question is the following: Is it possible to permute on the parametrized model/learner? When I call generateFeatureImportanceData on the learner I use in the benchmark experiment, the model is estimated again (ignoring the parametrization learned by sequenital optimization). Here is some code on the iris dataset to illustrate my question (no preprocessing and only for illustration).
library(dplyr)
library(mlr)
library(mlrMBO)
library(e1071)
nr_inner_cv <- 3L
nr_outer_cv <- 2L
inner = makeResampleDesc(
"CV"
, iters = nr_inner_cv # folds used in tuning/bayesian optimization)
learner_knn_base = makeLearner(id = "knn", "classif.knn")
par.set = makeParamSet(
makeIntegerParam("k", lower = 2L, upper = 10L)
)
ctrl = makeMBOControl()
ctrl <- makeMBOControl(propose.points = 1L)
ctrl <- setMBOControlTermination(ctrl, iters = 10L)
ctrl <- setMBOControlInfill(ctrl, crit = crit.ei, filter.proposed.points = TRUE)
set.seed(500)
tune.ctrl <- makeTuneControlMBO(
mbo.control = ctrl,
mbo.design = generateDesign(n = 10L, par.set = par.set)
)
learner_knn = makeTuneWrapper(learner = learner_knn_base
, resampling = inner
, par.set = par.set
, control = tune.ctrl
, show.info = TRUE
)
learner_nb <- makeLearner(
id = "naiveBayes"
,"classif.naiveBayes"
)
lrns = list(
learner_knn
, learner_nb
)
rdesc = makeResampleDesc("CV", iters = nr_outer_cv)
set.seed(12345)
bmr = mlr::benchmark(lrns, tasks = iris.task, show.info = FALSE,
resamplings = rdesc, models = TRUE, keep.extract = TRUE)