зеркало из https://github.com/microsoft/LightGBM.git
[python] fix early_stopping_round = 0 (#3211)
* Update engine.py * Update sklearn.py
This commit is contained in:
Родитель
1e2013a306
Коммит
aef50f8614
|
@ -211,7 +211,7 @@ def train(params, train_set, num_boost_round=100,
|
|||
elif isinstance(verbose_eval, integer_types):
|
||||
callbacks.add(callback.print_evaluation(verbose_eval))
|
||||
|
||||
if early_stopping_rounds is not None:
|
||||
if early_stopping_rounds is not None and early_stopping_rounds > 0:
|
||||
callbacks.add(callback.early_stopping(early_stopping_rounds, first_metric_only, verbose=bool(verbose_eval)))
|
||||
|
||||
if learning_rates is not None:
|
||||
|
@ -548,7 +548,7 @@ def cv(params, train_set, num_boost_round=100,
|
|||
for i, cb in enumerate(callbacks):
|
||||
cb.__dict__.setdefault('order', i - len(callbacks))
|
||||
callbacks = set(callbacks)
|
||||
if early_stopping_rounds is not None:
|
||||
if early_stopping_rounds is not None and early_stopping_rounds > 0:
|
||||
callbacks.add(callback.early_stopping(early_stopping_rounds, first_metric_only, verbose=False))
|
||||
if verbose_eval is True:
|
||||
callbacks.add(callback.print_evaluation(show_stdv=show_stdv))
|
||||
|
|
|
@ -602,7 +602,7 @@ class LGBMModel(_LGBMModelBase):
|
|||
if evals_result:
|
||||
self._evals_result = evals_result
|
||||
|
||||
if early_stopping_rounds is not None:
|
||||
if early_stopping_rounds is not None and early_stopping_rounds > 0:
|
||||
self._best_iteration = self._Booster.best_iteration
|
||||
|
||||
self._best_score = self._Booster.best_score
|
||||
|
|
Загрузка…
Ссылка в новой задаче