[英]Rewriting ParamSet ids from mlr3::paradox()
Let's say I have the following ParamSet
object:假设我有以下
ParamSet
object:
my_ps = paradox::ps(
minsplit = p_int(1, 64, logscale = TRUE),
cp = p_dbl(1e-04, 1, logscale = TRUE))
Is it possible to rename minsplit
to survTree.minsplit
without changing anything else?是否可以在不更改任何其他内容的情况下将
minsplit
重命名为survTree.minsplit
?
The reason for this is that I use some learners as part of a GraphLearner
and so their parameters names changed and I would like to have some code that adds the learner$id
in front the parameters to use later for tuning (rather than rewriting them from scratch with the new names)这样做的原因是我使用一些学习者作为
GraphLearner
的一部分,因此他们的参数名称发生了变化,我希望有一些代码在参数前面添加learner$id
以便稍后用于调整(而不是重写它们用新名字划破)
I think I have a partial solution here.我想我在这里有一个部分解决方案。 It is only partial, because it does not support the transformation.
它只是部分的,因为它不支持转换。
Where it works:它在哪里工作:
library(paradox)
my_ps = paradox::ps(
minsplit = p_int(1, 64),
cp = p_dbl(1e-04, 1)
)
my_ps$set_id = "john"
my_psc = ParamSetCollection$new(list(my_ps))
print(my_psc)
#> <ParamSetCollection>
#> id class lower upper nlevels default value
#> 1: john.minsplit ParamInt 1e+00 64 64 <NoDefault[3]>
#> 2: john.cp ParamDbl 1e-04 1 Inf <NoDefault[3]>
Created on 2022-12-07 by the reprex package (v2.0.1)由reprex package (v2.0.1) 创建于 2022-12-07
Where it does not:哪里没有:
library(paradox)
my_ps = paradox::ps(
minsplit = p_int(1, 64, logscale = TRUE),
cp = p_dbl(1e-04, 1)
)
my_ps$set_id = "john"
my_psc = ParamSetCollection$new(list(my_ps))
#> Error in .__ParamSetCollection__initialize(self = self, private = private, : Building a collection out sets, where a ParamSet has a trafo is currently unsupported!
Created on 2022-12-07 by the reprex package (v2.0.1)由reprex package (v2.0.1) 创建于 2022-12-07
The underlying problem is that we did not solve the problem of how to reconcile the parameter transformations of individual ParamSets and a possible parameter transformation of the ParamSetCollection
潜在的问题是我们没有解决如何协调各个 ParamSet 的参数转换和
ParamSetCollection
的可能参数转换的问题
I fear that there is currently no neat solution for your problem.我担心目前没有解决您的问题的完美方法。
Sorry I can not comment yet, this is not exactly the solution you are looking for but I hope this will fix the problem you are having.抱歉,我还不能发表评论,这不是您正在寻找的解决方案,但我希望这能解决您遇到的问题。
You can set the param_space
in the learner, before putting it in the graph, ie sticking with your search space.您可以在学习者中设置
param_space
,然后再将其放入图表中,即坚持您的搜索空间。 After you create the GraphLearner
regularly it will have the desired search space.定期创建
GraphLearner
后,它将具有所需的搜索空间。
A concrete example:一个具体的例子:
library(mlr3verse)
learner = lrn("regr.rpart", cp = to_tune(0.1, 0.2))
glrn = as_learner(po("pca") %>>% po("learner", learner))
at = auto_tuner(
"random_search",
glrn,
rsmp("holdout"),
term_evals = 10
)
task = tsk("mtcars")
at$train(task)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.