Nround parameter in XGboost

xgboost

#1

Hi All,

i was implementing xgb code is like below,

bst <- xgboost(data = as.matrix(train.boost), label = lable.train, max.depth = 2, eta = 1, nthread = 2, nround = 20, objective = "binary:logistic")

so i am surprised with the result of xgb, especially with nround

nround when -> 5 it gave train-error:0.175896 [final pass]
nround when -> 10 it gave train-error:0.154723 [final pass]
nround when ->20 it gave train-error:0.114007 [final pass]
nround when ->30 it gave train-error:0.099349 [final pass]

i think when i am using nround as high number it is overfitting the data, So i am confused, I want to know how to choose ideal value of nround.

Thanks


#2

@ajas.bakran : Make a cross validation to compare see the test error is decreasing or not. You can also use Xgb.cv method which does the same thing.


#3

Hi @ajas.bakran.

To add to the answer of @aayushmnit , you can also add early stopping to say 10 or 15 in xgboost to make it stop when the test error does not reduces for 10 or 15 continuous rounds instead of manually running it for x nrounds and comparing their test errors.


#4

@aayushmnit@sauravkaushik8 …Thanks guys…it is quite useful…