Dr. Who
Dr. Who

Reputation: 141

Why doesnt the early.stop.round argument in xgboost work?

I try to use the early.stop.round argument in the xgb.cv function of the xgboost library, however, I got an error. After I leave the early.stop.round unspecified, the function runs without any problem. What did I do wrong?

Here is my example code:

library(xgboost)

train = matrix(as.numeric(1:100),20,5)
Y = rep(c(0,1),10)
dtrain = xgb.DMatrix(train, label=Y)

#cross validation when early.stop.round =5, gives an error
CV = xgb.cv(data = dtrain, nround=200, nfold =2, metrics=list("auc"), 
            objective = "binary:logistic",early.stop.round = 5)


#cross validation when early.stop.round is not specified, works
CV = xgb.cv(data = dtrain, nround=200, nfold =2, metrics=list("auc"),
            objective = "binary:logistic")

I am using xgboost_0.4-2

Upvotes: 0

Views: 2613

Answers (1)

Jazz
Jazz

Reputation: 46

Looks like something goes wrong when using the metrics parameter and early.stop simultaneously. Remove metrics and use early.stop with eval_metric="auc" instead.

Upvotes: 3

Related Questions