我正在通过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函数来看,参数 missing 似乎采用从-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中的missing = [特定值])?还有其他事吗还是该警告不是引起关注的原因?
非常感谢您的澄清。
答案 0 :(得分:2)
此警告来自ParamHelpers,在这种情况下无害。这是标准检查,没有考虑到特殊情况。