"""Logic helpers for the **Overview** tab.""" from typing import List from .state import app_state from .utils import compute_model_rankings_new, create_model_summary_card_new __all__ = ["create_overview"] def create_overview( selected_models: List[str], top_n: int, score_significant_only: bool = False, quality_significant_only: bool = False, sort_by: str = "quality_asc", min_cluster_size: int = 1, ) -> str: """Return the HTML snippet that summarises model performance.""" if not app_state["metrics"]: return "Please load data first using the 'Load Data' tab." if not selected_models: return "Please select at least one model to display." # 1. Compute global rankings and filter to selection model_rankings = compute_model_rankings_new(app_state["metrics"]) filtered_rankings = [ (name, stats) for name, stats in model_rankings if name in selected_models ] # Sort so "all" appears first, then the rest by their rankings all_models = [(name, stats) for name, stats in filtered_rankings if name == "all"] other_models = [(name, stats) for name, stats in filtered_rankings if name != "all"] filtered_rankings = all_models + other_models if not filtered_rankings: return "No data available for selected models." # 2. Assemble HTML overview_html = """
Top distinctive clusters where each model shows unique behavioural patterns. Frequency shows what percentage of a model's battles resulted in that behavioural pattern.
+0.15
) means the model hits the behaviour more often than average.-0.08
) means it appears less often.proportion_delta
field in model_cluster_scores.json
.quality_delta
metric dictionary in model_cluster_scores.json
.