Empty evaluation list in early stopping should produce meaningful error message (#4633)

* Empty evaluation list should not break early stopping

* Fix lint

* Update callback.py
This commit is contained in:
Philip Hyunsu Cho 2019-07-04 13:27:18 -07:00 committed by GitHub
parent 4df246191f
commit b7a1f22d24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -222,9 +222,9 @@ def early_stop(stopping_rounds, maximize=False, verbose=True):
def callback(env): def callback(env):
"""internal function""" """internal function"""
score = env.evaluation_result_list[-1][1]
if not state: if not state:
init(env) init(env)
score = env.evaluation_result_list[-1][1]
best_score = state['best_score'] best_score = state['best_score']
best_iteration = state['best_iteration'] best_iteration = state['best_iteration']
maximize_score = state['maximize_score'] maximize_score = state['maximize_score']