Skip to content

Adaptive learner hyperparameter in RFE [Question] #72

Answered by be-marc
bblodfon asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, we recently introduced callbacks to do these hacky things. Something like this should work.

library(mlr3verse)
library(mlr3fselect)

callback = callback_fselect("mtry",
  on_eval_after_design = function(callback, context) {
    x = length(context$design$task[[1]]$feature_names)
    mtry.ratio = 1- ((x - 1) / (60 - 1))
    context$design$learner[[1]]$param_set$set_values(mtry.ratio = mtry.ratio)
  })

instance = FSelectInstanceSingleCrit$new(
  task = tsk("spam"),
  learner = lrn('classif.ranger', num.threads = 10, num.trees = 50, importance = 'permutation', mtry.ratio = 0.1),
  resampling = rsmp("insample"),
  measure = msr("oob_error"),
  terminator = trm("none"),
  callbacks = call…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by bblodfon
Comment options

bblodfon
Jan 26, 2023
Maintainer Author

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@bblodfon
Comment options

bblodfon Jan 27, 2023
Maintainer Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #71 on January 27, 2023 08:49.