"vscode:/vscode.git/clone" did not exist on "a8adaa9270a88544838c707b5a13b652d57483f6"
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:
def _format_eval_result(value: _EvalResultTuple, show_stdv: bool) -> str:
"""Format metric string."""
if len(value) == 4:
return f"{value[0]}'s {value[1]}: {value[2]:g}"
elif len(value) == 5:
if show_stdv:
return f"{value[0]}'s {value[1]}: {value[2]:g} + {value[4]:g}" # type: ignore[misc]
else:
return f"{value[0]}'s {value[1]}: {value[2]:g}"
else:
raise ValueError("Wrong metric value")
dataset_name, metric_name, metric_value, *_ = value
out = f"{dataset_name}'s {metric_name}: {metric_value:g}"
# tuples from cv() sometimes have a 5th item, with standard deviation of
# the evaluation metric (taken over all cross-validation folds)
if show_stdv and len(value) == 5:
out += f" + {value[4]:g}"
return out
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