什么警告“NA用作学习者参数缺失的默认值”是指mlr?

问题描述 投票:1回答:1

我通过mlr包运行分类xgboost。我的数据缺少值,我想保留(也就是说,我想保留这些观察结果,我想避免估算)。我知道mlr中的xgboost实现可以处理缺失值。但是,我不明白mlr的makeLearner函数提供的警告。

我试图阅读文档,并在其他人的代码中发现了这个警告。但我没有看到以对我有意义的方式处理警告。

例如,我已经阅读了关于警告的讨论,但它没有为我澄清事情:https://github.com/mlr-org/mlr/pull/1225

调用makeLearner函数时会出现警告:

xgb_learner <- makeLearner(
  "classif.xgboost",
  predict.type = "prob",
  par.vals = list(
    objective = "binary:logistic",
    eval_metric = "error",
    nrounds = 200,
    missing = NA,
    max_depth = 6,
    eta = 0.1,
    gamma = 5,
    colsample_bytree = 0.5,
    min_child_weight = 1,
    subsample = 0.7

  )
)
Warning in makeParam(id = id, type = "numeric", learner.param = TRUE, lower = lower,  :
  NA used as a default value for learner parameter missing.
ParamHelpers uses NA as a special value for dependent parameters.

我的缺失值目前被编码为缺失值(即NA)。很明显,R从以下方面认识到它们:

> sum(is.na(training$day))
[1] 58

从getParamSet函数看,缺少的参数似乎从-Inf到Inf获取数值。那么,也许NA不是有效值?

> getParamSet("classif.xgboost")
Warning in makeParam(id = id, type = "numeric", learner.param = TRUE, lower = lower,  :
  NA used as a default value for learner parameter missing.
ParamHelpers uses NA as a special value for dependent parameters.
                                Type  len             Def               Constr Req Tunable Trafo
booster                     discrete    -          gbtree gbtree,gblinear,dart   -    TRUE     -
watchlist                    untyped    -          <NULL>                    -   -   FALSE     -
eta                          numeric    -             0.3               0 to 1   -    TRUE     -
gamma                        numeric    -               0             0 to Inf   -    TRUE     -
max_depth                    integer    -               6             1 to Inf   -    TRUE     -
min_child_weight             numeric    -               1             0 to Inf   -    TRUE     -
subsample                    numeric    -               1               0 to 1   -    TRUE     -
colsample_bytree             numeric    -               1               0 to 1   -    TRUE     -
colsample_bylevel            numeric    -               1               0 to 1   -    TRUE     -
num_parallel_tree            integer    -               1             1 to Inf   -    TRUE     -
lambda                       numeric    -               1             0 to Inf   -    TRUE     -
lambda_bias                  numeric    -               0             0 to Inf   -    TRUE     -
alpha                        numeric    -               0             0 to Inf   -    TRUE     -
objective                    untyped    - binary:logistic                    -   -   FALSE     -
eval_metric                  untyped    -           error                    -   -   FALSE     -
base_score                   numeric    -             0.5          -Inf to Inf   -   FALSE     -
max_delta_step               numeric    -               0             0 to Inf   -    TRUE     -
missing                      numeric    -                          -Inf to Inf   -   FALSE     -

我是否需要将这些重新编码为特定值,然后传递给mlr(通过在makeLearner中缺少= [特定值])?做点别的吗?或者这个警告不是引起关注的原因?

非常感谢任何澄清。

r xgboost mlr
1个回答
2
投票

这个警告来自ParamHelpers,在这种情况下是无害的。这是一个标准检查,不考虑特定情况。

© www.soinside.com 2019 - 2024. All rights reserved.