Handles formatted output of evaluation results.
| 75 | |
| 76 | |
| 77 | class ResultsPrinter: |
| 78 | """Handles formatted output of evaluation results.""" |
| 79 | |
| 80 | def __init__(self): |
| 81 | self.console = Console() |
| 82 | |
| 83 | def print_header(self, text: str): |
| 84 | """Print a styled header.""" |
| 85 | self.console.print(f"\n[bold blue]{text}[/bold blue]") |
| 86 | |
| 87 | def print_score(self, category: str, score: float, indent: int = 0): |
| 88 | """Print a score with proper formatting.""" |
| 89 | indent_str = " " * indent |
| 90 | self.console.print(f"{indent_str}[cyan]{category}:[/cyan] [yellow]{score:.2f}[/yellow]") |
| 91 | |
| 92 | def create_results_table(self, category: str, scores: Dict[str, float]) -> Table: |
| 93 | """Create a rich table for displaying results.""" |
| 94 | table = Table(title=f"{category} Results", show_header=True, header_style="bold magenta") |
| 95 | table.add_column("Metric", style="cyan") |
| 96 | table.add_column("Score", justify="right", style="yellow") |
| 97 | |
| 98 | for metric, score in scores.items(): |
| 99 | table.add_row(metric, f"{score:.2f}") |
| 100 | |
| 101 | return table |
| 102 | |
| 103 | def print_summary_panel(self, total_score: float, num_categories: int): |
| 104 | """Print a panel with summary information.""" |
| 105 | panel = Panel( |
| 106 | f"[bold green]Total Score: {total_score:.2f}[/bold green]\n", |
| 107 | # f"[blue]Average per category: {total_score/num_categories:.2f}[/blue]", |
| 108 | title="Evaluation Summary", |
| 109 | border_style="green" |
| 110 | ) |
| 111 | self.console.print(panel) |
| 112 | |
| 113 | |
| 114 | class WorldModelEvaluator: |