Spaces:
Runtime error
Runtime error
Deploy Space: update src
Browse files58 unmodified lines5960616263646598 unmodified lines16416516616616716816816916917017117217317417517617717817317918018118218318418518683 unmodified lines270271272273274275276384 unmodified lines6616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057069 unmodified lines71671771867067167267367467567667771972072172258 unmodified lines "eval_metrics/MSE[mean]", "eval_metrics/mean_weighted_sum_quantile_loss",]GEOMEAN_EPSILON = 1e-12
VALUE_COLUMNS = ["MSE", "CRPS", RANK_SCORE_COLUMN] + [ METRIC_LABELS[m] for m in DISPLAY_METRICS if METRIC_LABELS[m] not in {"MSE", "CRPS"}98 unmodified lines
def format_number(value): """Format a displayed leaderboard metric with a fixed two-decimal precision.""" """Format a displayed leaderboard metric without hiding tiny non-zero values.""" if pd.isna(value): return np.nan return f"{float(value):.2f}" return "n/a" number = float(value) if not np.isfinite(number): return "n/a" if number != 0.0 and abs(number) < 0.005: return f"{number:.2e}" return f"{number:.2f}"
def aggregate_gmean(series: pd.Series) -> float: values = series.dropna() values = pd.to_numeric(series, errors="coerce").dropna() values = values[np.isfinite(values) & (values >= 0.0)] if values.empty: return np.nan values = values.clip(lower=GEOMEAN_EPSILON) return float(stats.gmean(values))
83 unmodified lines
for metric in METRIC_COLUMNS: df[metric] = pd.to_numeric(df[metric], errors="coerce") df.loc[~np.isfinite(df[metric]), metric] = np.nan
return _add_per_dataset_ranks(df)
384 unmodified lines return ordered
def _parse_timestamp(value: object) -> datetime | None: if not value or value == "n/a": return None try: return datetime.fromisoformat(str(value).replace("Z", "+00:00")) except (TypeError, ValueError): return None
def _read_json(path: Path) -> dict: if not path.exists(): return {} try: return json.loads(path.read_text()) except (OSError, json.JSONDecodeError): return {}
def leaderboard_refresh_timestamp(root_dir: str = "results") -> str: """Return the latest timestamp that can change leaderboard-visible results.""" root = Path(root_dir) candidates: list[datetime] = []
status = _read_json(root / "online_status.json") for key in ("finished_at", "pushed_at"): parsed = _parse_timestamp(status.get(key)) if parsed is not None: candidates.append(parsed)
for metadata_name in ("metadata.json", "live_metadata.json"): metadata = _read_json(root / "aggregates" / metadata_name) parsed = _parse_timestamp(metadata.get("generated_at")) if parsed is not None: candidates.append(parsed)
if not candidates: return "n/a" return format_timestamp_utc8(max(candidates).isoformat())
def build_leaderboard_summary_html(root_dir: str = "results") -> str: df = prepare_results_df(root_dir) if df.empty:9 unmodified lines models = df["model"].nunique() datasets = df["dataset"].nunique() domains = df["domain"].nunique() if "domain" in df.columns else 0 last_refresh = "n/a" status_path = Path(root_dir) / "online_status.json" if status_path.exists(): try: status = json.loads(status_path.read_text()) last_refresh = format_timestamp_utc8(status.get("finished_at", "")) except Exception: pass last_refresh = leaderboard_refresh_timestamp(root_dir)
return f""" <div class="summary-grid">src/utils.py+54-12