首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用mlr3tuningspaces设置xgboost超带优化的“预算”标签?

如何用mlr3tuningspaces设置xgboost超带优化的“预算”标签?
EN

Stack Overflow用户
提问于 2022-06-22 22:38:15
回答 1查看 94关注 0票数 1

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

下面,我复制了mlr3hyperband包示例,以说明我的问题:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-23 09:03:29

谢谢你指出这个。我将把预算标签添加到默认的搜索空间中。在此之前,您可以使用此代码。

代码语言:javascript
复制
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
)

更新28.06.2022

版本0.3.0中的新API是

代码语言:javascript
复制
learner = lts(lrn("classif.xgboost"), nrounds = to_tune(p_int(1000, 5000, tags = "budget"))
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72722714

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档