fix early stopping
This commit is contained in:
parent
83ace55f51
commit
90096e718c
@ -196,7 +196,7 @@ xgb.cv <- function(params=list(), data, nrounds, nfold, label = NULL, missing =
|
|||||||
bestScore = score
|
bestScore = score
|
||||||
bestInd = i
|
bestInd = i
|
||||||
} else {
|
} else {
|
||||||
if (i-bestInd>early_stop_round) {
|
if (i-bestInd>=early_stop_round) {
|
||||||
earlyStopflag = TRUE
|
earlyStopflag = TRUE
|
||||||
cat('Stopping. Best iteration:',bestInd)
|
cat('Stopping. Best iteration:',bestInd)
|
||||||
break
|
break
|
||||||
|
|||||||
@ -187,7 +187,7 @@ xgb.train <- function(params=list(), data, nrounds, watchlist = list(),
|
|||||||
bestScore = score
|
bestScore = score
|
||||||
bestInd = i
|
bestInd = i
|
||||||
} else {
|
} else {
|
||||||
if (i-bestInd>early_stop_round) {
|
if (i-bestInd>=early_stop_round) {
|
||||||
earlyStopflag = TRUE
|
earlyStopflag = TRUE
|
||||||
cat('Stopping. Best iteration:',bestInd)
|
cat('Stopping. Best iteration:',bestInd)
|
||||||
break
|
break
|
||||||
|
|||||||
@ -34,6 +34,6 @@ print ('start training with early Stopping setting')
|
|||||||
# training with customized objective, we can also do step by step training
|
# training with customized objective, we can also do step by step training
|
||||||
# simply look at xgboost.py's implementation of train
|
# simply look at xgboost.py's implementation of train
|
||||||
bst <- xgb.train(param, dtrain, num_round, watchlist, logregobj, evalerror, maximize = FALSE,
|
bst <- xgb.train(param, dtrain, num_round, watchlist, logregobj, evalerror, maximize = FALSE,
|
||||||
earlyStopRound = 3)
|
early.stop.round = 3)
|
||||||
bst <- xgb.cv(param, dtrain, num_round, nfold=5, obj=logregobj, feval = evalerror,
|
bst <- xgb.cv(param, dtrain, num_round, nfold=5, obj=logregobj, feval = evalerror,
|
||||||
maximize = FALSE, earlyStopRound = 3)
|
maximize = FALSE, early.stop.round = 3)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user