2017-02-18 90 views
0

我在xgboost R包中使用xgb.train()以适合分类模型。我想弄清楚什么是停止树的最佳迭代。我设置了early_stop_rounds = 6,通过观察每个迭代的指标,我可以清楚地看到,验证数据上的auc性能达到最大值,然后下降。但是,模型不会停止并继续前进,直到达到指定的圆形。xgboost R包early_stop_rounds不会触发

问题1:当验证性能开始下降时,它是在迭代中定义的最佳模型(对于给定的参数)吗?

问题2:为什么模型在验证时auc开始减少时不会停止?

问题3:如何最大化parameter = FALSE是什么意思?如果它设置为FALSE,什么会使它停止?当设置了early_stop_round时它是否必须是FALSE?

问题4:模型如何知道监视列表中的验证数据是哪一个?我见过有人用test =,eval =,validation1 = etc?

谢谢!

param<-list(
    objective="binary:logistic", 
    booster="gbtree", 
    eta=0.02, #Control the learning rate 
    max.depth=3, #Maximum depth of the tree 
    subsample=0.8, #subsample ratio of the training instance 
    colsample_bytree=0.5 # subsample ratio of columns when constructing each  tree 
) 

watchlist<-list(train=mtrain,validation=mtest) 

sgb_model<-xgb.train(params=param, # this is the modeling parameter set  above 
       data = mtrain, 
       scale_pos_weight=1, 
       max_delta_step=1, 
       missing=NA, 
       nthread=2, 
       nrounds = 500, #total run 1500 rounds 
       verbose=2, 
       early_stop_rounds=6, #if performance not improving for 6 rounds, model iteration stops 
       watchlist=watchlist, 
       maximize=FALSE, 
       eval.metric="auc" #Maximize AUC to evaluate model 
       #metric_name = 'validation-auc' 
       ) 

回答

0
  • 答1:不,不是最好的,但不够好偏见方差 折衷的观点。
  • 回答2:它的工作原理可能与您的代码存在一些问题。您能否在每次助推步骤中分享列车和测试装置AUC的进度输出以证明这一点?如果你100%确定它没有工作,那么你可以在XGBoost git项目中提交错误票证。
  • 答案3:Maximize=FALSE是用于自定义优化功能(说定制merror类型的东西)。你总是希望最大化/增加AUC,所以Maximize=TRUE对你更好。
  • 答案4:它主要是基于位置的。先培训部分。接下来应该进入验证/评估。