odunbar commited on
Commit Β·
bafeb07
1
Parent(s): e26bc15
swap dropdown to multi-pills-selector
Browse filesFiles changed (2)
24 unmodified lines25262728293031323396 unmodified lines130131132133134135169 unmodified lines30530630730830931031131248 unmodified lines36136236336436536636724 unmodified lineswhatever `selected_benchmark` is currently chosen.3. **Controls β always visible**, not collapsed. Look for `st.subheader("Scoring &Target Controls")`: target-level radio, scoring-mode radio (+ blend-weight sliderwhen "Custom Blend" is selected), and the "Methods to display in charts" multiselect.These used to be wrapped in `st.expander(..., expanded=False)`; that was removed sousers don't have to open a dropdown to see or change the target level.4. **Charts** β main "Mean Forward Model Runs vs Ensemble Size" chart, then (UQ only)the "Mean Iterations for Coverage" chart, then (if `show_failure_panel=True`) thefailure-rate bar chart.96 unmodified lines---## Leaderboard line chartThe chart that appears above the table ("Mean Forward Model Runs vs Ensemble Size") is169 unmodified linesWhen calling `_method_color()`, compute `present_abbrevs` from the actual DataFrame(s)plotted in that chart section (e.g. `all_ens_combos["abbreviation"].unique()`), **not**from the global "Methods to display in charts" multiselect. A method can be selected inthe multiselect but have no data for the current benchmark/target combination β includingit in the legend anyway would be misleading. Each chart section (main chart, UQ iterschart, failure-rate chart) computes and passes its own `present_abbrevs`, since the setof methods with data can differ section to section (e.g. a method might have forward-run48 unmodified lines`leaderboard_df`-emptiness gate (main chart) or have its own independent emptinesscheck (UQ iters chart, failure panel) β see the gotcha under "Page layout" above.4. If the chart colors by `abbreviation`: use `_method_color(present_abbrevs)` computedfrom that section's actual plotted data, not the global multiselect.5. Restart or clear Streamlit cache to pick up Python changes (code changes take effect onrestart; cache only matters for data changes).6. Smoke-test with a benchmark/target combination where every run fails (all-DNF) to24 unmodified lines2526272829303132333496 unmodified lines131132133134135136137138139140141142143144145146147148149150151152153154155156157158169 unmodified lines32832933033133233333433548 unmodified lines38438538638738838939024 unmodified lineswhatever `selected_benchmark` is currently chosen.3. **Controls β always visible**, not collapsed. Look for `st.subheader("Scoring &Target Controls")`: target-level radio, scoring-mode radio (+ blend-weight sliderwhen "Custom Blend" is selected), and the "Methods to display in charts" pillsselector (see "Methods selector" below). These used to be wrapped in`st.expander(..., expanded=False)`; that was removed so users don't have to open adropdown to see or change the target level.4. **Charts** β main "Mean Forward Model Runs vs Ensemble Size" chart, then (UQ only)the "Mean Iterations for Coverage" chart, then (if `show_failure_panel=True`) thefailure-rate bar chart.96 unmodified lines---## Methods selectorThe "Methods to display in charts" control (grep for that string in `leaderboard.py`) uses`st.pills(..., selection_mode="multi")`, not `st.multiselect` or `st.selectbox`. Prefer`st.pills` in multi mode whenever the goal is "let users see and toggle all options at aglance" β every option renders as a clickable button, so nothing is hidden behind adropdown the way `st.multiselect`'s collapsed chip list is. `selection_mode` defaults to`"single"`, so it must be passed explicitly to allow more than one method selected at once;in multi mode `st.pills` returns a list, same shape as `st.multiselect`. It was added inStreamlit 1.40 β the project's pinned `streamlit` (currently 1.57.0 in the `.venv`) alreadycovers it.It reads/writes the same `key=k_methods` session-state slot the old multiselect used, sothe surrounding logic is unaffected by the widget swap: the default-selection (top 5 byrank) and stale-selection-pruning code sets `st.session_state[k_methods]` *before* thewidget call (search for `st.session_state[k_methods] = valid_saved if valid_saved elsedefault_methods`), and the widget itself is called with `key=k_methods` and no `default=`argument. If you add a new always-visible, multi-choice control elsewhere in the app,follow this same pattern rather than reaching for `st.multiselect` by default.---## Leaderboard line chartThe chart that appears above the table ("Mean Forward Model Runs vs Ensemble Size") is169 unmodified linesWhen calling `_method_color()`, compute `present_abbrevs` from the actual DataFrame(s)plotted in that chart section (e.g. `all_ens_combos["abbreviation"].unique()`), **not**from the global "Methods to display in charts" pills selector. A method can be selectedthere but have no data for the current benchmark/target combination β includingit in the legend anyway would be misleading. Each chart section (main chart, UQ iterschart, failure-rate chart) computes and passes its own `present_abbrevs`, since the setof methods with data can differ section to section (e.g. a method might have forward-run48 unmodified lines`leaderboard_df`-emptiness gate (main chart) or have its own independent emptinesscheck (UQ iters chart, failure panel) β see the gotcha under "Page layout" above.4. If the chart colors by `abbreviation`: use `_method_color(present_abbrevs)` computedfrom that section's actual plotted data, not the global pills selector.5. Restart or clear Streamlit cache to pick up Python changes (code changes take effect onrestart; cache only matters for data changes).6. Smoke-test with a benchmark/target combination where every run fails (all-DNF) to
278 unmodified lines279280281282283284285286287288289290291129 unmodified lines42142242342442542658 unmodified lines4854864874884894904914924934943 unmodified lines49849950050150250385 unmodified lines58959059159259359469 unmodified lines664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712278 unmodified linesfwdruns_weight = current_fwdruns_weight_percent / 100.0ensemble_weight = 1.0 - fwdruns_weight# Available methods for the current benchmark selection; used to populate the# multiselect and to prune any stale saved selections when the benchmark changes.available_methods = sorted(filtered["abbreviation"].dropna().unique().tolist())saved_methods = st.session_state.get(k_methods, available_methods)valid_saved = [m for m in saved_methods if m in available_methods]st.session_state[k_methods] = valid_saved if valid_saved else available_methodsdef build_scored_table(input_df: pd.DataFrame, add_rank: bool = True) -> pd.DataFrame:ranking_source = input_df[input_df[target_str_col] == selected_target]if ranking_source.empty:129 unmodified linesleaderboard_df = build_scored_table(filtered, add_rank=True)# Attach the four taxonomy tags (constant per abbreviation, so this is a# plain lookup merge rather than a groupby key threaded through every# aggregation above).58 unmodified lines),)st.multiselect("Methods to display in charts",options=available_methods,key=k_methods,)selected_methods = st.session_state.get(k_methods, available_methods)3 unmodified linesst.divider()# --- Charts (rendered above the leaderboard table, below the controls) ---if not leaderboard_df.empty:st.subheader("Mean Forward Model Runs vs Ensemble Size")chart_source = filtered[filtered[target_str_col] == selected_target]85 unmodified linesif chart_layers:st.altair_chart(alt.layer(*chart_layers), use_container_width=True)# Mean-iterations-for-coverage section (UQ only, when budget_store provided)if budget_store is not None and not budget_store.empty:69 unmodified linesif iters_layers:st.altair_chart(alt.layer(*iters_layers), use_container_width=True)# Failure panel β rendered regardless of whether the scored table has rowsif show_failure_panel:failure_source = filtered[filtered[target_str_col] == selected_target]failure_source = failure_source[failure_source["abbreviation"].isin(selected_methods)]if not failure_source.empty:failure_df = failure_source.groupby(["abbreviation", "ensemble_size"], as_index=False).agg(mean_failure_rate=("failure_rate", "mean"))failure_df = failure_df.sort_values("ensemble_size")st.subheader(f"Failure Rate of Hitting Target {selected_target}")ens_ticks_fail = sorted(failure_df["ensemble_size"].unique().tolist())failure_chart = (alt.Chart(failure_df).mark_bar().encode(x=alt.X("ensemble_size:O",title="Ensemble Size",sort=[str(e) for e in ens_ticks_fail],axis=alt.Axis(labelAngle=0),),xOffset=alt.XOffset("abbreviation:N"),y=alt.Y("mean_failure_rate:Q",title="Failure Rate (%)",scale=alt.Scale(domain=[0, 100]),),color=_method_color(failure_df["abbreviation"].unique().tolist()),tooltip=[alt.Tooltip("abbreviation:N", title="Method"),alt.Tooltip("ensemble_size:O", title="Ensemble Size"),alt.Tooltip("mean_failure_rate:Q", format=".1f", title="Failure Rate (%)"),],))ceiling_line = (alt.Chart(alt.Data(values=[{}])).mark_rule(color="grey", strokeDash=[4, 4]).encode(y=alt.datum(100)))st.altair_chart(failure_chart + ceiling_line, use_container_width=True)st.divider()# --- Leaderboard table (rendered below the charts) ---278 unmodified lines279280281282283284129 unmodified lines41441541641741841942042142242342442542642742842943043143243343443543643758 unmodified lines4964974984995005015025035045055065073 unmodified lines51151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156285 unmodified lines64864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871969 unmodified lines789790791792793794278 unmodified linesfwdruns_weight = current_fwdruns_weight_percent / 100.0ensemble_weight = 1.0 - fwdruns_weightdef build_scored_table(input_df: pd.DataFrame, add_rank: bool = True) -> pd.DataFrame:ranking_source = input_df[input_df[target_str_col] == selected_target]if ranking_source.empty:129 unmodified linesleaderboard_df = build_scored_table(filtered, add_rank=True)# Methods available for the current benchmark; used to populate the multiselect# and to prune stale saved selections when the benchmark changes. The default# selection (first load, or once a prior selection becomes entirely invalid) is# the top 5 methods by performance Rank, not every method β the "Methods to# display in charts" multiselect lets a user opt into seeing more.available_methods = sorted(filtered["abbreviation"].dropna().unique().tolist())if not leaderboard_df.empty and leaderboard_df["Rank"].notna().any():default_methods = (leaderboard_df.dropna(subset=["Rank"]).sort_values("Rank")["abbreviation"].head(5).tolist())else:# All runs failed at this target (or no data) β show every method so the# all-DNF warning/chart-suppression path still has something to work with.default_methods = available_methodssaved_methods = st.session_state.get(k_methods, default_methods)valid_saved = [m for m in saved_methods if m in available_methods]st.session_state[k_methods] = valid_saved if valid_saved else default_methods# Attach the four taxonomy tags (constant per abbreviation, so this is a# plain lookup merge rather than a groupby key threaded through every# aggregation above).58 unmodified lines),)st.pills("Methods to display in charts",options=available_methods,selection_mode="multi",key=k_methods,help="Defaults to the top 5 methods by current rank β click to add or remove.",)selected_methods = st.session_state.get(k_methods, available_methods)3 unmodified linesst.divider()# --- Charts (rendered above the leaderboard table, below the controls) ---# Failure panel β shown first so failures are visible before the budget/# iterations charts below. Rendered regardless of whether the scored table# has rows (own emptiness check on failure_source).if show_failure_panel:failure_source = filtered[filtered[target_str_col] == selected_target]failure_source = failure_source[failure_source["abbreviation"].isin(selected_methods)]if not failure_source.empty:failure_df = failure_source.groupby(["abbreviation", "ensemble_size"], as_index=False).agg(mean_failure_rate=("failure_rate", "mean"))failure_df = failure_df.sort_values("ensemble_size")st.subheader(f"Failure Rate of Hitting Target {selected_target}")ens_ticks_fail = sorted(failure_df["ensemble_size"].unique().tolist())failure_chart = (alt.Chart(failure_df).mark_bar().encode(x=alt.X("ensemble_size:O",title="Ensemble Size",sort=[str(e) for e in ens_ticks_fail],axis=alt.Axis(labelAngle=0),),xOffset=alt.XOffset("abbreviation:N"),y=alt.Y("mean_failure_rate:Q",title="Failure Rate (%)",scale=alt.Scale(domain=[0, 100]),),color=_method_color(failure_df["abbreviation"].unique().tolist()),tooltip=[alt.Tooltip("abbreviation:N", title="Method"),alt.Tooltip("ensemble_size:O", title="Ensemble Size"),alt.Tooltip("mean_failure_rate:Q", format=".1f", title="Failure Rate (%)"),],))ceiling_line = (alt.Chart(alt.Data(values=[{}])).mark_rule(color="grey", strokeDash=[4, 4]).encode(y=alt.datum(100)))st.altair_chart(failure_chart + ceiling_line, use_container_width=True)st.divider()if not leaderboard_df.empty:st.subheader("Mean Forward Model Runs vs Ensemble Size")chart_source = filtered[filtered[target_str_col] == selected_target]85 unmodified linesif chart_layers:st.altair_chart(alt.layer(*chart_layers), use_container_width=True)st.caption("Note: plotted means here and in the charts below are averaged over ""successful seeds only β runs that never reached the target are excluded. ""An β at zero marks ensemble sizes where every seed failed."+ (" Failure frequency is shown in the failure-rate chart further down."if show_failure_panelelse ""))# Mean-iterations section for the Optimization board: n_iterations =# metric / ensemble_size, since every registered method's forward-model# call count scales as ensemble_size (or restart count) per outer-loop# iteration β see method_registry.py taxonomy. The UQ board instead# renders its own iterations chart below from real k_iter data via# budget_store, so this section only applies when none is supplied.if budget_store is None and not all_ens_combos.empty:iters_chart_df = chart_df.assign(mean_iterations=lambda d: d["mean_forward_runs"] / d["ensemble_size"])iters_fail_df = fail_df.assign(mean_iterations=0.0)st.subheader("Mean Iterations to Reach Target vs Ensemble Size")opt_iters_layers = []if not iters_chart_df.empty:opt_iters_layers.append(alt.Chart(iters_chart_df).mark_line(point=True).encode(x=alt.X("ensemble_size:Q",title="Ensemble Size",axis=alt.Axis(values=ens_ticks, format="d"),),y=alt.Y("mean_iterations:Q", title="Mean Iterations"),color=main_color,tooltip=["abbreviation", "ensemble_size", alt.Tooltip("mean_iterations:Q", format=".2f")],))if not iters_fail_df.empty:y_iters_opt = (alt.Y("mean_iterations:Q", title="Mean Iterations", scale=alt.Scale(domain=[0, 1]))if all_failedelse alt.Y("mean_iterations:Q", title="Mean Iterations"))opt_iters_layers.append(alt.Chart(iters_fail_df).mark_point(shape="cross", angle=45, size=200, filled=True, opacity=1.0).encode(x=alt.X("ensemble_size:Q",title="Ensemble Size",axis=alt.Axis(values=ens_ticks, format="d"),),y=y_iters_opt,color=main_color,tooltip=[alt.Tooltip("abbreviation:N", title="Method"),alt.Tooltip("ensemble_size:Q", title="Ensemble Size"),alt.Tooltip("mean_iterations:Q", title="Value (all failed)"),],))if opt_iters_layers:st.altair_chart(alt.layer(*opt_iters_layers), use_container_width=True)# Mean-iterations-for-coverage section (UQ only, when budget_store provided)if budget_store is not None and not budget_store.empty:69 unmodified linesif iters_layers:st.altair_chart(alt.layer(*iters_layers), use_container_width=True)st.divider()# --- Leaderboard table (rendered below the charts) ---
.claude/skills/leaderboard-manager/references/manage-display.md+29-6
src/common/leaderboard.py+133-51