mlr-org / mlr3

mlr3: Machine Learning in R - next generation
https://mlr3.mlr-org.com
GNU Lesser General Public License v3.0
947 stars 85 forks source link

feat: add callbacks for resample and benchmark #1214

Open be-marc opened 1 day ago

be-marc commented 1 day ago
callback = callback_workhorse(
  id = "mlr3.selected_features",
  on_workhorse_before_result = function(callback, context) {
    context$env$learner$state$selected_features = setdiff(context$env$learner$model$frame$var, "<leaf>")
  }
)

learner = lrn("classif.rpart")
task = tsk("iris")
resampling = rsmp("cv", folds = 3)

rr = resample(task, learner, resampling, callbacks = callback)

rr$learners[[1]]$state$selected_features