diff --git a/fugue_tune/tune.py b/fugue_tune/tune.py index b412731..5fd558c 100644 --- a/fugue_tune/tune.py +++ b/fugue_tune/tune.py @@ -447,15 +447,21 @@ def outputter(df: LocalDataFrame) -> None: ] def show(subdf: pd.DataFrame) -> None: + if subdf.shape[0] == 0: + return subdf = subdf.sort_values("__fmin_value__").head(top) - title = ", ".join(str(subdf[k][0]) for k in keys) if len(keys) > 0 else "" + title = ( + json.dumps({k: str(subdf[k].iloc[0]) for k in keys}) + if len(keys) > 0 + else "" + ) pdf = pd.DataFrame([json.loads(x) for x in subdf["__fmin_params__"]]) fig = plt.figure(figsize=(12, 3 * len(pdf.columns))) if len(keys) > 0: fig.suptitle( title, va="center", - size=20, + size=15, weight="bold", y=0.93, ) diff --git a/tests/fugue_tune/test_sklearn.py b/tests/fugue_tune/test_sklearn.py index d16d111..12cbea4 100644 --- a/tests/fugue_tune/test_sklearn.py +++ b/tests/fugue_tune/test_sklearn.py @@ -131,6 +131,7 @@ def test_suggest_sk_model(tmpdir): feature_prefix="f_", save_model=True, partition_keys=["p"], + visualize_top_n=2, ) assert len(res) == 4 print(res)