简体   繁体   English

使用 mlr3 进行超参数调整的贝叶斯优化

[英]Bayesian optimization for hyperparameter tuning using mlr3

Are there any hyperparameter tuners using Bayesian optimization within the mlr3 ecosystem?mlr3生态系统中是否有使用贝叶斯优化的超参数调谐器? In particular as an argument in the wrapper function特别是作为包装器 function 中的参数

tuner = tnr("grid_search", resolution = 10)

? ?

Otherwise, what would be a recommended tuning method supported by mlr3 ?否则,什么是mlr3支持的推荐调整方法?

UPDATE: I tried following @Sebastian's mlr3mbo link -- in particular the "Simple Tuning Example Using Defaults" section.更新:我尝试关注@Sebastian 的mlr3mbo 链接——特别是“使用默认值的简单调整示例”部分。

However, when I tried to use it in tune_nested但是,当我尝试在 tune_nested 中使用它时

rr = tune_nested(
    method = "mbo", 
    task,
    learner=lrn("surv.cv_glmnet",  nfolds=3, type.measure = "C", alpha = to_tune(0.01, 1)) ,
    inner_resampling = rsmp("cv", folds = 10), 
    outer_resampling = rsmp("cv", folds = 10), 
    measure = msr("surv.cindex"), 
    term_evals = 20
    )

I get the error:我得到错误:

Error in auto_tuner(method, learner, inner_resampling, measure, term_evals,  : 
  Assertion on 'method' failed: Must be element of set {'cmaes','design_points','gensa','grid_search','irace','nloptr','random_search'}, but is 'mbo'.
Calls: tune_nested ... auto_tuner -> assert_choice -> makeAssertion -> mstop

UPDATE2 : after using devtools::install_github("mlr-org/mlr3mbo@add_tuner") as @Sebastian helpfully suggested, I get instead the following error message: UPDATE2 :使用devtools::install_github("mlr-org/mlr3mbo@add_tuner")作为@Sebastian 有用的建议后,我得到以下错误消息:

Error in .__ParamSet__search_space(self = self, private = private, super = super,  : 
  Assertion on 'names(values)' failed: Must have names.

Does alpha = to_tune(0.01, 1) within lrn() not sufficiently specify the required name and value range of the HP alpha ? lrn() 中的alpha = to_tune(0.01, 1) lrn()不足以指定 HP alpha所需的名称和值范围?

Is there any way around this?有没有办法解决? Thanks!谢谢!

SOLUTION : Thanks to @Sebastian who fixed this -- in his comment:解决方案:感谢@Sebastian 解决了这个问题——在他的评论中:

manually define the search_space like search_space = ps(alpha = p_dbl(0.01, 1)) and then pass it as the search_space argument to tune_nested手动定义search_space ,如search_space = ps(alpha = p_dbl(0.01, 1)) ,然后将其作为search_space参数传递给tune_nested

Super!极好的!

Just checking in to add a few comments and answer your latest question @Alex: A minor note on the error:只需签入以添加一些评论并回答您的最新问题@Alex:关于错误的小提示:

Error in .__ParamSet__search_space(self = self, private = private, super = super,  : 
  Assertion on 'names(values)' failed: Must have names.

This was rather caused due to old bbotk / paradox versions that have been fixed upstream and you most likely should no longer encounter any errors anymore.这是由于上游已修复的旧bbotk / paradox版本造成的,您很可能不再遇到任何错误。 The manual fix is no longer needed.不再需要手动修复。

The BO Tuner will live in mlr3mbo and a PR will be merged soon. BO Tuner 将存在于mlr3mbo中,并且 PR 将很快合并。

In general mlr3mbo is slowly but steady getting to a point where it can be considered stable and will be pushed to CRAN.一般来说mlr3mbo会缓慢但稳定地达到可以被认为是稳定的程度,并将被推送到 CRAN。 I do agree that some documentation is still missing.我同意仍然缺少一些文档。 Also, one or two gallery posts about the inner workings of mlr3mbo will be provided in the near future.此外,近期还将提供一两个关于mlr3mbo内部工作原理的画廊帖子。

Regarding:关于:

One last question: is there a reference for how the optimiser works, eg the maths behind it? I searched and only found mlr3mbo.mlr-org.com/reference/mlr_optimizers_mbo.html which doesn't have many details.

All current implementations are somewhat standard/basic BO stuff, therefore we currently did not included detailed descriptions of the algorithms (but we may do this in the future).所有当前的实现都是标准/基本的 BO 东西,因此我们目前没有包括算法的详细描述(但我们将来可能会这样做)。

(sequential) (single-criteria) BO (as eg, implemented in bayesopt_ego ) works by fitting a Surrogate model to your evaluated points, learning the relationship between inputs and outputs. (顺序)(单一标准)BO(例如,在bayesopt_ego中实现)通过将Surrogate model 拟合到您的评估点来工作,学习输入和输出之间的关系。 Based on an acquisition function AcqFunction (relying on this surrogate) that encodes for each potential next candidate to evaluate the gain in evaluation (ie, how much can I expect to improve my solution if I evaluate this candidate) you find the next point to query, evaluate it and update your archive of evaluated points and start over again with refitting the surrogate.基于获取 function AcqFunction (依赖于这个代理项),它为每个潜在的下一个候选者编码以评估评估中的增益(即,如果我评估这个候选者,我可以期望改进我的解决方案多少)你找到下一个要查询的点,评估它并更新您的评估点档案,然后重新开始重新安装代理。

I highlighted the respective classes/functions and most of them include references to standard papers where you can learn more about the maths/technical details.我强调了各自的类/函数,其中大多数都包含对标准论文的引用,您可以在其中了解更多关于数学/技术细节的信息。

Also, if you find mlr3mbo useful or have any further comments/questions, feel free to also communicate with us via GitHub https://github.com/mlr-org/mlr3mbo .此外,如果您发现mlr3mbo有用或有任何进一步的意见/问题,请随时通过 GitHub https://github.com/mlr-org/mlr3mbo与我们交流。 Issues/open questions etc. are welcome!欢迎提出问题/未决问题等!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM