-
Hi Marc (@be-marc), This is more of a is-it-possible-somehow question as I know it can't be done via conventional means - but maybe you can think of a way to help me hack this if you like :) In the example I provided in #67 with a random forest
Now, the RFE procedure will choose a series of feature subset sizes to check. In my case scenario, I have large task with ~10000 features as a starting point. Using
Could I have somehow a simple function that adapts the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
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 = callback,
store_models = TRUE
)
fselector = fs("rfe", feature_fraction = 0.8, n_features = 2)
fselector$optimize(instance)
# mtry.ratio increases
mlr3misc::map(as.data.table(instance$archive)$resample_result, function(rr) rr$learner$param_set$values$mtry.ratio) |
Beta Was this translation helpful? Give feedback.
-
Nice! will try this tomorrow, I guess the |
Beta Was this translation helpful? Give feedback.
-
Download the latest version 0.9.1 from CRAN. The |
Beta Was this translation helpful? Give feedback.
Hey, we recently introduced callbacks to do these hacky things. Something like this should work.