在mlr3调优步骤中,我尝试使用bfgs作为优化问题的求解器。我检查了文档,以了解如何添加求解程序所需的渐变。
虽然我能够将它添加到纯nloptr中,但我无法在bbotk或mlr3级别上这样做。一个极小的例子说明了我的意思:
library(mlr3)
library(paradox)
library(mlr3tuning)
inner_resampling = rsmp("cv", folds = 5)
terminator <- trm("evals",n_evals = 10)
tsk <- tsk("pima")
learner <- lrn("classif.rpart")
search_space <- ps(
cp = p_dbl(lower = 1e-4, upper = 0.1)
)
tuner <- tnr("nloptr",algorithm = "NLOPT_LD_LBFGS")
inst <- TuningInstanceSingleCrit$new(
task = tsk,
learner = learner,
resampling = inner_resampling,
terminator = terminator
search_space = search_space,
measure = msr("classif.ce")
)
tuner$optimize(inst)结果是:
Error in is.nloptr(ret) :
A gradient for the objective function is needed by algorithm NLOPT_LD_LBFGS but was not supplied.当选择无梯度算法(例如NLOPT_LN_BOBYQA)时,一切都很好。
我现在的问题是:这一般都有可能吗?还是基于梯度的算法不适用于bbotk抽象级别及以上?我试着检查代码(尽可能为我:-),但是我没有找到添加梯度函数的槽。
提前谢谢彼得
发布于 2022-02-23 15:46:48
在这种黑匣子优化中没有梯度。原则上,您可以通过经验确定梯度,但这违背了试图通过尽可能少的评估来实现性能改进的精神。
没有计划支持在mlr3中进行调优的梯度。当然,如果您对此感兴趣,欢迎您提供:)
https://stackoverflow.com/questions/71232647
复制相似问题