Unverified Commit 480600b3 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[python-package] simplify eval result printing (#6749)


Co-authored-by: default avatarJosé Morales <jmoralz92@gmail.com>
parent 8eb3c3c6
...@@ -73,15 +73,13 @@ class CallbackEnv: ...@@ -73,15 +73,13 @@ class CallbackEnv:
def _format_eval_result(value: _EvalResultTuple, show_stdv: bool) -> str: def _format_eval_result(value: _EvalResultTuple, show_stdv: bool) -> str:
"""Format metric string.""" """Format metric string."""
if len(value) == 4: dataset_name, metric_name, metric_value, *_ = value
return f"{value[0]}'s {value[1]}: {value[2]:g}" out = f"{dataset_name}'s {metric_name}: {metric_value:g}"
elif len(value) == 5: # tuples from cv() sometimes have a 5th item, with standard deviation of
if show_stdv: # the evaluation metric (taken over all cross-validation folds)
return f"{value[0]}'s {value[1]}: {value[2]:g} + {value[4]:g}" # type: ignore[misc] if show_stdv and len(value) == 5:
else: out += f" + {value[4]:g}"
return f"{value[0]}'s {value[1]}: {value[2]:g}" return out
else:
raise ValueError("Wrong metric value")
class _LogEvaluationCallback: class _LogEvaluationCallback:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment