【问题标题】:How to set "budget" tag for xgboost hyperband optimization with mlr3tuningspaces?如何使用 mlr3tuningspaces 为 xgboost 超频带优化设置“预算”标签?
【发布时间】:2022-06-28 19:15:41
【问题描述】:

我正在尝试调整xgboost超频带我想使用建议的默认调整空间mlr3tuningspaces包裹。但是,在使用 lts 时,我找不到如何用“预算”标记超参数。

下面,我转载了mlr3 超频带包示例来说明我的问题:

library(mlr3verse)
library(mlr3hyperband)
library(mlr3tuningspaces)

## this does not work, because I don\'t know how to tag a hyperparameter 
## with \"budget\" while using the suggested tuning space
search_space = lts(\"classif.xgboost.default\")
search_space$values

## this works because it has a hyperparameter (nrounds) tagged with \"bugdget\"
search_space = ps(
  nrounds = p_int(lower = 1, upper = 16, tags = \"budget\"), 
  eta = p_dbl(lower = 0, upper = 1),
  booster = p_fct(levels = c(\"gbtree\", \"gblinear\", \"dart\"))
)

# hyperparameter tuning on the pima indians diabetes data set
instance = tune(
  method = \"hyperband\",
  task = tsk(\"pima\"),
  learner = lrn(\"classif.xgboost\", eval_metric = \"logloss\"),
  resampling = rsmp(\"cv\", folds = 3),
  measures = msr(\"classif.ce\"),
  search_space = search_space,
  term_evals = 100
)

# best performing hyperparameter configuration
instance$result

    标签: xgboost mlr3


    【解决方案1】:

    感谢您指出了这一点。我将预算标签添加到默认搜索空间。在此之前,您可以使用此代码。

    library(mlr3hyperband)
    library(mlr3tuningspaces)
    library(mlr3learners)
    
    # get learner with search space in one go
    learner = lts(lrn("classif.xgboost"))
    
    # overwrite nrounds with budget tag
    learner$param_set$values$nrounds = to_tune(p_int(1000, 5000, tags = "budget"))
    
    instance = tune(
      method = "hyperband",
      task = tsk("pima"),
      learner = learner,
      resampling = rsmp("cv", folds = 3),
      measures = msr("classif.ce"),
      term_evals = 100
    )
    

    2022 年 6 月 28 日更新

    0.3.0 版中的新 API 是

    learner = lts(lrn("classif.xgboost"), nrounds = to_tune(p_int(1000, 5000, tags = "budget"))
    

    【讨论】:

    • 感谢您提出的解决方法。当我运行learner = lts(lrn("classif.xgboost")) 行时,它会在 RStudio 中打开一个调试窗口,当我单击“继续”时它会工作,但我想我会提到它。
    • 此错误已在 0.3.0 中修复
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-21
    • 2020-03-18
    • 2020-01-10
    • 2012-05-14
    • 2018-03-16
    • 2020-09-10
    • 2020-06-10
    相关资源
    最近更新 更多