Skip to content

Commit

Permalink
Simplifying if condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
matsuken92 committed Jun 7, 2019
1 parent 2f4e2b0 commit 9387197
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions python-package/lightgbm/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from operator import gt, lt

from .compat import range_
from .basic import LightGBMError


class EarlyStopException(Exception):
Expand Down Expand Up @@ -228,10 +227,9 @@ def _callback(env):
metric_key = env.evaluation_result_list[i][1]
if metric_key.split(" ")[0] == "train":
continue # train metric doesn't used on early stopping.
if first_metric_only:
if eval_metric is not None:
if metric_key != "valid {}".format(eval_metric) and metric_key != eval_metric and eval_metric != "":
continue
if first_metric_only and eval_metric is not None and metric_key != "valid {}".format(eval_metric) and \
metric_key != eval_metric and eval_metric != "":
continue
score = env.evaluation_result_list[i][2]
if best_score_list[i] is None or cmp_op[i](score, best_score[i]):
best_score[i] = score
Expand Down

0 comments on commit 9387197

Please sign in to comment.