我正在使用mlr包运行分类xgboost。我的数据中有缺失值,我希望保留这些观测,并避免插值。我理解mlr中的xgboost实现可以处理缺失值。但是,我不理解mlr的makeLearner函数提供的警告。
我尝试阅读文档并在其他人的代码中找到了这个警告。但是,我没有看到解释这个警告的方法让我感到有道理。
例如,我已经阅读了警告的讨论,但它没有为我澄清问题: https://github.com/mlr-org/mlr/pull/1225 当调用makeLearner函数时,警告出现:
从getParamSet函数中可以看出,参数missing取值范围为从负无穷到正无穷的数字。因此,也许NA不是一个有效的值?
我尝试阅读文档并在其他人的代码中找到了这个警告。但是,我没有看到解释这个警告的方法让我感到有道理。
例如,我已经阅读了警告的讨论,但它没有为我澄清问题: 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取值范围为从负无穷到正无穷的数字。因此,也许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 -
我需要将这些内容重新编码为特定值,然后通过missing = [specific value]在makeLearner中传递给mlr吗?还是需要采取其他措施?或者这个警告不需要担心?
非常感谢您的任何澄清。
ParamHelpers
处理xgboost
的missing
参数的方式,其默认值为NA
。我尝试将其设置为其他值,但警告仍然存在。 - xm1