2017-02-18 36 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:它主要是基於位置的。先培訓部分。接下來應該進入驗證/評估。