How to apply search space to AutoFSelector #41
-
Hi, I am new to mlr3. After reading the content of basics and model optimization in mlr3 book, I am trying to apply a xgboost model to my data with mlr3. When I use Here is some code, task = mlr3::as_task_classif(data, target = target, id = "auto-feature-selector", positive = as.character(positive))
rm(data)
invisible(gc())
learner = mlr3::lrn("classif.xgboost", predict_type = "prob")
terminator = mlr3tuning::trm("evals", n_evals = 10)
fselector = mlr3fselect::fs("random_search")
resampling = mlr3::rsmp("holdout", ratio = 0.9)
measure = mlr3::msr("classif.prauc")
# rewrite parameters
#learner$param_set$values$nrounds <- paradox::to_tune(c(1, 100))
at = AutoFSelector$new(
learner = learner,
resampling = resampling,
measure = measure,
terminator = terminator,
fselector = fselector
) I am trying to define a search space so the AutoFSelector can run xgboost with different parameters. e.g., set This doesn't work:
Is there an easy way to do this? Best, Shixiang |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
cc @be-marc |
Beta Was this translation helpful? Give feedback.
-
library(mlr3tuning)
library(mlr3fselect)
library(mlr3learners)
task = tsk("pima")
# feature selection on pima data set
fselect_instance = fselect(
method = "random_search",
task = task,
learner = lrn("classif.xgboost", nrounds = 100),
resampling = rsmp("cv", folds = 3),
measure = msr("classif.ce"),
term_evals = 10
)
# subset task to selected features
task$select(fselect_instance$result_feature_set)
# tune rpart on pima data set
tuning_instance = tune(
method = "grid_search",
task = task,
learner = lrn("classif.xgboost", nrounds = to_tune(100, 1000)),
resampling = rsmp("cv", folds = 3),
measure = msr("classif.ce"),
term_evals = 10,
resolution = 5
) Note that the tuning result depends on the previously selected features. |
Beta Was this translation helpful? Give feedback.
…