Skip to content

Commit

Permalink
add legend in the help
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre committed Jan 9, 2025
1 parent 4b8be36 commit ad20a1c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
16 changes: 14 additions & 2 deletions skore/src/skore/sklearn/_estimator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from io import StringIO

import joblib
from rich.console import Console
from rich.console import Console, Group
from rich.panel import Panel
from rich.tree import Tree

Expand Down Expand Up @@ -42,10 +42,22 @@ def _get_method_description(self, method):
else "No description available"
)

def _get_help_legend(self):
"""Get the help legend."""
return None

def _create_help_panel(self):
"""Create the help panel."""
if self._get_help_legend():
content = Group(
self._create_help_tree(),
f"\n\nLegend:\n{self._get_help_legend()}",
)
else:
content = self._create_help_tree()

return Panel(
self._create_help_tree(),
content,
title=self._get_help_panel_title(),
expand=False,
border_style="orange1",
Expand Down
5 changes: 5 additions & 0 deletions skore/src/skore/sklearn/_estimator/metrics_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,11 @@ def _create_help_tree(self):
def _get_help_panel_title(self):
return f"[bold cyan]{self._icon} Available metrics methods[/bold cyan]"

def _get_help_legend(self):
return (
"[cyan](↗︎)[/cyan] higher is better [orange1](↘︎)[/orange1] lower is better"
)

def _get_help_tree_title(self):
return "[bold cyan]reporter.metrics[/bold cyan]"

Expand Down
7 changes: 6 additions & 1 deletion skore/src/skore/sklearn/_estimator/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,12 @@ def _get_cached_response_values(
def _get_help_panel_title(self):
return (
f"[bold cyan]📓 Tools to diagnose estimator "
"{self.estimator_name}[/bold cyan]"
f"{self.estimator_name}[/bold cyan]"
)

def _get_help_legend(self):
return (
"[cyan](↗︎)[/cyan] higher is better [orange1](↘︎)[/orange1] lower is better"
)

def _create_help_tree(self):
Expand Down

0 comments on commit ad20a1c

Please sign in to comment.