【问题标题】:R xgboost predict with early.stop.roundR xgboost 用 early.stop.round 预测
【发布时间】:2016-08-21 18:04:54
【问题描述】:

我有以下代码。假设优化在 600 轮后停止,最佳轮数为 450。将使用哪个模型进行预测 - 第 450 轮之后还是第 600 轮之后?

watchlist <- list(val=dval,train=dtrain)

param <- list(  objective           = "binary:logistic", 
                booster             = "gbtree",
                eval_metric         = "auc",
                eta                 = 0.02,
                max_depth           = 7,
                subsample           = 0.6,
                colsample_bytree    = 0.7
)

clf <- xgb.train(   params              = param, 
                    data                = dtrain, 
                    nrounds             = 2000, 
                    verbose             = 0,
                    early.stop.round    = 150,
                    watchlist           = watchlist,
                    maximize            = TRUE
)

preds <- predict(clf, test)

【问题讨论】:

    标签: r xgboost


    【解决方案1】:

    经过一番研究,我自己找到了答案。 Predict 将在第 600 轮后使用模型。如果想使用效果最好的模型,应该使用preds &lt;- predict(clf, test, ntreelimit=clf$bestInd)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-19
      • 1970-01-01
      • 2020-07-17
      • 2016-06-02
      • 2020-01-10
      • 2016-10-29
      • 2019-07-20
      相关资源
      最近更新 更多