R XGBoost-未在命名空间中导出预测
我试图在R中使用一个多类因变量来调优xgboost模型。我使用MLR来实现这一点,但是我遇到了一个错误,xgboost在其名称空间中没有predict,我假设MLR想要使用它。我在网上浏览了一下,发现其他人也遇到过类似的问题。然而,我不能完全理解已经提供的答案(例如),当我尝试实现它们时,问题仍然存在。我的代码如下:R XGBoost-未在命名空间中导出预测,r,xgboost,mlr,R,Xgboost,Mlr,我试图在R中使用一个多类因变量来调优xgboost模型。我使用MLR来实现这一点,但是我遇到了一个错误,xgboost在其名称空间中没有predict,我假设MLR想要使用它。我在网上浏览了一下,发现其他人也遇到过类似的问题。然而,我不能完全理解已经提供的答案(例如),当我尝试实现它们时,问题仍然存在。我的代码如下: # Tune parameters #create tasks train$result <- as.factor(train$result) # Needs to be
# Tune parameters
#create tasks
train$result <- as.factor(train$result) # Needs to be a factor variable for makeClass to work
test$result <- as.factor(test$result)
traintask <- makeClassifTask(data = train,target = "result")
testtask <- makeClassifTask(data = test,target = "result")
lrn <- makeLearner("classif.xgboost",predict.type = "response")
# Set learner value and number of rounds etc.
lrn$par.vals <- list(
objective = "multi:softprob", # return class with maximum probability,
num_class = 3, # There are three outcome categories
eval_metric="merror",
nrounds=100L,
eta=0.1
)
# Set parameters to be tuned
params <- makeParamSet(
makeDiscreteParam("booster",values = c("gbtree","gblinear")),
makeIntegerParam("max_depth",lower = 3L,upper = 10L),
makeNumericParam("min_child_weight",lower = 1L,upper = 10L),
makeNumericParam("subsample",lower = 0.5,upper = 1),
makeNumericParam("colsample_bytree",lower = 0.5,upper = 1)
)
# Set resampling strategy
rdesc <- makeResampleDesc("CV",stratify = T,iters=5L)
# search strategy
ctrl <- makeTuneControlRandom(maxit = 10L)
#parallelStartSocket(cpus = detectCores()) # Enable parallel processing
mytune <- tuneParams(learner = lrn
,task = traintask
,resampling = rdesc
,measures = acc
,par.set = params
,control = ctrl
,show.info = T)
有人知道我在这里该做什么吗
提前感谢。尝试升级mlr。xgboost学习者需要定期调整以适应其代码库中的更改。我升级到了开发版本,现在可以使用了。我可能应该在发布之前检查一下。谢谢你的帮助!尝试升级mlr。xgboost学习者需要定期调整以适应其代码库中的更改。我升级到了开发版本,现在可以使用了。我可能应该在发布之前检查一下。谢谢你的帮助!
packageVersion("xgboost")
[1] ‘0.6.4’
packageVersion("mlr")
[1] ‘2.8’