feat(dashboard): Genomes page (top-10 + inspection)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import streamlit as st
|
||||
|
||||
from multi_swarm.dashboard.data import (
|
||||
evaluations_df,
|
||||
genomes_df,
|
||||
get_repo,
|
||||
list_runs_df,
|
||||
)
|
||||
|
||||
st.title("Genomes")
|
||||
|
||||
db_path = st.session_state.get("db_path", "./runs.db")
|
||||
repo = get_repo(db_path)
|
||||
|
||||
runs = list_runs_df(repo)
|
||||
if runs.empty:
|
||||
st.info("Nessuna run.")
|
||||
st.stop()
|
||||
|
||||
selected = st.selectbox("Run", runs["id"].tolist())
|
||||
evals = evaluations_df(repo, selected)
|
||||
genomes = genomes_df(repo, selected)
|
||||
|
||||
if evals.empty:
|
||||
st.warning("Nessuna evaluation.")
|
||||
st.stop()
|
||||
|
||||
merged = evals.merge(
|
||||
genomes, left_on="genome_id", right_on="id", how="left", suffixes=("", "_g")
|
||||
)
|
||||
top = merged.sort_values("fitness", ascending=False).head(10)
|
||||
|
||||
st.subheader("Top-10 genomi (per fitness)")
|
||||
display_cols = [
|
||||
"genome_id",
|
||||
"fitness",
|
||||
"dsr",
|
||||
"sharpe",
|
||||
"max_dd",
|
||||
"n_trades",
|
||||
"cognitive_style",
|
||||
"temperature",
|
||||
"lookback_window",
|
||||
"feature_access",
|
||||
]
|
||||
existing = [c for c in display_cols if c in top.columns]
|
||||
st.dataframe(top[existing])
|
||||
|
||||
st.subheader("Ispezione genoma")
|
||||
gid = st.selectbox("Seleziona genome_id", top["genome_id"].tolist())
|
||||
row = merged[merged["genome_id"] == gid].iloc[0]
|
||||
|
||||
col1, col2 = st.columns(2)
|
||||
with col1:
|
||||
st.metric("fitness", f"{row['fitness']:.3f}")
|
||||
st.metric("DSR", f"{row['dsr']:.3f}")
|
||||
st.metric("Sharpe", f"{row['sharpe']:.3f}")
|
||||
with col2:
|
||||
st.metric("max DD", f"{row['max_dd']:.3f}")
|
||||
st.metric("trades", int(row["n_trades"]))
|
||||
st.metric("style", str(row.get("cognitive_style", "—")))
|
||||
|
||||
st.subheader("System prompt")
|
||||
st.code(row.get("system_prompt", "—"))
|
||||
|
||||
st.subheader("Raw LLM output")
|
||||
st.code(row.get("raw_text", "—"))
|
||||
|
||||
if row.get("parse_error"):
|
||||
st.error(f"Parse error: {row['parse_error']}")
|
||||
Reference in New Issue
Block a user