[XGBoost4J-Spark] bestIteration and bestScore for early stopping (#7095)
This commit is contained in:
@@ -242,11 +242,15 @@ public class XGBoost {
|
||||
if (score > bestScore) {
|
||||
bestScore = score;
|
||||
bestIteration = iter;
|
||||
booster.setAttr("best_iteration", String.valueOf(bestIteration));
|
||||
booster.setAttr("best_score", String.valueOf(bestScore));
|
||||
}
|
||||
} else {
|
||||
if (score < bestScore) {
|
||||
bestScore = score;
|
||||
bestIteration = iter;
|
||||
booster.setAttr("best_iteration", String.valueOf(bestIteration));
|
||||
booster.setAttr("best_score", String.valueOf(bestScore));
|
||||
}
|
||||
}
|
||||
if (earlyStoppingRounds > 0) {
|
||||
|
||||
Reference in New Issue
Block a user