Skip to content

Commit

Permalink
feat: Humanize plot names when converting to a CrossValidationItem
Browse files Browse the repository at this point in the history
  • Loading branch information
augustebaum committed Dec 20, 2024
1 parent c6fb23b commit 46685f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/diagnose/plot_cross_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
# We can also access the plot after we have stored the ``CrossValidationReporter``:
my_project.put("cross_validation_regression", reporter)
cv_item = my_project.get_item("cross_validation_regression")
cv_item.plots["compare_scores"]
cv_item.plots["Scores"]

# %%
# .. note::
Expand Down
9 changes: 8 additions & 1 deletion skore/src/skore/item/cross_validation_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,15 @@ def factory(cls, reporter: CrossValidationReporter) -> CrossValidationItem:
"hash": _hash_numpy(X_array),
}

humanized_plot_names = {
"compare_scores": "Scores",
"timing": "Timings",
"timing_normalized": "Normalized timings",
}
plots_bytes = {
plot_name: plotly.io.to_json(plot, engine="json").encode("utf-8")
humanized_plot_names[plot_name]: (
plotly.io.to_json(plot, engine="json").encode("utf-8")
)
for plot_name, plot in dataclasses.asdict(plots).items()
}

Expand Down

0 comments on commit 46685f8

Please sign in to comment.