Fix model slicing. (#7149)

* Use correct pointer.
* Remove best_iteration/best_score.
This commit is contained in:
Jiaming Yuan
2021-08-03 11:51:56 +08:00
committed by GitHub
parent 36346f8f56
commit d080b5a953
6 changed files with 37 additions and 5 deletions

View File

@@ -103,7 +103,9 @@ def _train_internal(params, dtrain,
# Due to compatibility with version older than 1.4, these attributes are added
# to Python object even if early stopping is not used.
bst.best_iteration = bst.num_boosted_rounds() - 1
bst.set_attr(best_iteration=str(bst.best_iteration))
bst.best_ntree_limit = (bst.best_iteration + 1) * num_parallel_tree
bst.set_attr(best_ntree_limit=str(bst.best_ntree_limit))
# Copy to serialise and unserialise booster to reset state and free
# training memory