在MLR中,如何仅将逻辑超参数设置为TRUE或FALSE?

在MLR中,如何仅将逻辑超参数设置为TRUE或FALSE?,r,hyperparameters,mlr,R,Hyperparameters,Mlr,我使用这个数据集尝试使用classif.ada进行分类任务 library(mlr) data("HouseVotes84") #Using HouseVotes84 as Classification Task Dataset and mtcars as Regression Task Dataset dummy_data_classif <- HouseVotes84[,2:length(colnames(HouseVotes84))] %>% muta

我使用这个数据集尝试使用classif.ada进行分类任务

library(mlr)
data("HouseVotes84")
#Using HouseVotes84 as Classification Task Dataset and mtcars as Regression Task Dataset
dummy_data_classif <- HouseVotes84[,2:length(colnames(HouseVotes84))] %>% 
  mutate_if(is.factor, as.numeric)
dummy_data_classif <- data.frame(cbind(Class=HouseVotes84[,1], dummy_data_classif))
dummy_data_classif[is.na(dummy_data_classif)] <- 0
dummy_data_classif_numeric <- dummy_data_classif[-1] %>%
  mutate_if(is.factor, as.numeric)
dummy_data_classif_numeric <- data.frame(cbind(dummy_data_classif[1], 
                                               dummy_data_classif_numeric))
colnames(dummy_data_classif_numeric) <- colnames(dummy_data_classif)

如何使
“model.coef”
仅包含
FALSE

要为学习者创建固定参数,请在创建学习者时在
参数VAL中设置该参数。看

参数集中指定的参数将始终在指定范围内进行调整


PS:使用
为全局变量指定参数集为学习者创建固定参数,在创建学习者时在
par.vals
中设置该参数。看

参数集中指定的参数将始终在指定范围内进行调整


PS:使用
将参数集指定给GlobalEnv如果希望固定一个值且不包含在搜索空间中,则必须手动设置此参数的值并将其从搜索空间中排除:

hyperparam$pars$model.coef = NULL
learner <- makeLearner("classif.ada", par.vals = list(model.coef = FALSE))
lrn_tune <- tuneParams(learner = learner, task = task, 
                       resampling = resampling_method, 
                       control = hyper_search, par.set = hyperparam)
hyperparam$pars$model.coef=NULL

学习者如果希望一个值固定且不包含在搜索空间中,则必须手动设置此参数的值,并将其从搜索空间中排除:

hyperparam$pars$model.coef = NULL
learner <- makeLearner("classif.ada", par.vals = list(model.coef = FALSE))
lrn_tune <- tuneParams(learner = learner, task = task, 
                       resampling = resampling_method, 
                       control = hyper_search, par.set = hyperparam)
hyperparam$pars$model.coef=NULL

首先,您定义
lrn抱歉,该方法实际上是classif.ada,我使用parse,因为字符串paramset的结果来自内置函数:),之后需要它动态生成param sets首先,您定义
lrn抱歉,该方法实际上是classif.ada,我使用parse,由于字符串paramset的结果来自一个内置函数:),以后需要它动态生成param sets我先前试图从搜索空间中删除model.coef,但由于默认值为TRUE,如果为TRUE,则会由于某种原因导致调整失败,因此,我可能需要直接更改:)我之前曾尝试从搜索空间中删除model.coef,但由于默认值为TRUE,如果为TRUE,则会因某种原因导致调整失败,因此我可能需要直接更改:)
[Tune] Started tuning learner classif.ada for parameter set:
                   Type len   Def               Constr Req Tunable Trafo
iter            integer   -     -            50 to 250   -    TRUE     -
max.iter        integer   -     -            30 to 200   -    TRUE     -
model.coef      logical   - FALSE                    -   -   FALSE     -
loss           discrete   -     - exponential,logistic   -    TRUE     -
type           discrete   -     - discrete,real,gentle   -    TRUE     -
nu              numeric   -     -             0 to 100   -    TRUE     -
bag.frac        numeric   -     -               0 to 1   -    TRUE     -
bag.shift       logical   -     -                    -   -    TRUE     -
delta           numeric   -     -           0 to 1e-07   -    TRUE     -
minsplit        integer   -     -              1 to 30   -    TRUE     -
minbucket       integer   -     -              1 to 20   -    TRUE     -
cp              numeric   -     -               0 to 1   -    TRUE     -
maxcompete      integer   -     -               0 to 6   -    TRUE     -
maxsurrogate    integer   -     -             0 to 7.5   -    TRUE     -
usesurrogate   discrete   -     -                0,1,2   -    TRUE     -
surrogatestyle discrete   -     -                  0,1   -    TRUE     -
maxdepth        integer   -     -              1 to 30   -    TRUE     -
With control class: TuneControlRandom
Imputation value: 1
[Tune-x] 1: iter=233; max.iter=141; model.coef=FALSE; loss=exponential; type=gentle; nu=63.5; bag.frac=0.686; bag.shift=TRUE; delta=3.49e-08; minsplit=21; minbucket=2; cp=0.881; maxcompete=1; maxsurrogate=2; usesurrogate=2; surrogatestyle=0; maxdepth=17
[Tune-y] 1: mmce.test.mean=0.0598309; time: 0.8 min
[Tune-x] 2: iter=230; max.iter=115; model.coef=TRUE; loss=exponential; type=gentle; nu=39.6; bag.frac=0.35; bag.shift=TRUE; delta=4.87e-08; minsplit=1; minbucket=2; cp=0.523; maxcompete=4; maxsurrogate=7; usesurrogate=0; surrogatestyle=1; maxdepth=21
Error in if (any(wt < 0)) stop("negative weights not allowed") : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In log((1 - errm)/errm) :
 Error in if (any(wt < 0)) stop("negative weights not allowed") : 
  missing value where TRUE/FALSE needed 
hyperparam$pars$model.coef = NULL
learner <- makeLearner("classif.ada", par.vals = list(model.coef = FALSE))
lrn_tune <- tuneParams(learner = learner, task = task, 
                       resampling = resampling_method, 
                       control = hyper_search, par.set = hyperparam)