[jvm-packages]xgboost4j support `early stop` on Validation set


#1

Hi all
I am using XGBoostClassifier, setting two parameters num_early_stopping_rounds and maximize_evaluation_metrics. Compared to python package, I found there is no way to set validation set like watchlist. Is this feature supported or still in the plan.
Please let me know, thank you very much


#2

Currently work in progress: https://github.com/dmlc/xgboost/pull/3910


#3

Got it ,thank you for your reply


#4

hi,@hcho3
I have tried to use early stop@v0.81, but i think there’s some mistakes here:

boolean onTrack = false;
float[] criterion = metrics[metrics.length - 1];
for (int shift = 0; shift < Math.min(iter, earlyStoppingRounds) - 1; shift++) {
  onTrack |= maximizeEvaluationMetrics ?
          criterion[iter - shift] >= criterion[iter - shift - 1] :
          criterion[iter - shift] <= criterion[iter - shift - 1];
}
return onTrack;

}

Usualy, iter starts from 0, so it will never enter the for loop, and onTrack will allways equal false, and the training will stop after 1 rounds. Obviously, this is not what we want.


#5

@houyadong Can you file a pull request to fix it?


#6

Thank you for your reply, but i find it has been fixed in the master branch: