eval_metrics print fixed (#4803)

This commit is contained in:
Cyprien Ricque 2019-08-29 05:52:18 +02:00 committed by Jiaming Yuan
parent 516955564b
commit 830e73901d

View File

@ -19,11 +19,11 @@ def _get_callback_context(env):
def _fmt_metric(value, show_stdv=True): def _fmt_metric(value, show_stdv=True):
"""format metric string""" """format metric string"""
if len(value) == 2: if len(value) == 2:
return '%s:%g' % (value[0], value[1]) return '{0}:{1:.5f}'.format(value[0], value[1])
if len(value) == 3: if len(value) == 3:
if show_stdv: if show_stdv:
return '%s:%g+%g' % (value[0], value[1], value[2]) return '{0}:{1:.5f}+{2:.5f}'.format(value[0], value[1], value[2])
return '%s:%g' % (value[0], value[1]) return '{0}:{1:.5f}'.format(value[0], value[1])
raise ValueError("wrong metric value") raise ValueError("wrong metric value")