Spaces:
Running
Running
Leaderboard, win-rate matrix, target data tab
Browse files5 unmodified lines678910111213145 unmodified linessdk: staticpinned: falselicense: apache-2.0short_description: Backtest scores of open-predico forecasts for Predico---Dashboard for [open-predico](https://github.com/arnaud-vs/open-predico). Reads backtest predictions from the public dataset [open-predico/benchmark](https://huggingface.co/datasets/open-predico/benchmark).Streamlit app run in the browser with [stlite](https://github.com/whitphx/stlite) (static Space, no server). Locally: `pip install -r requirements.txt && streamlit run app.py`.5 unmodified lines678910111213145 unmodified linessdk: staticpinned: falselicense: apache-2.0short_description: Backtest leaderboard and target data for open-predico---Dashboard for [open-predico](https://github.com/arnaud-vs/open-predico). Backtest leaderboard, win rates and error breakdowns, plus an exploration of the target series. Reads the public dataset [open-predico/benchmark](https://huggingface.co/datasets/open-predico/benchmark).Streamlit app run in the browser with [stlite](https://github.com/whitphx/stlite) (static Space, no server). Locally: `pip install -r requirements.txt && streamlit run app.py`.
1234567898 unmodified lines18192021222320 unmodified lines4445464748495051521 unmodified line545556575859609 unmodified lines70717273747576777879808182834 unmodified lines888990919293949596971 unmodified line991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941952 unmodified lines1981992002012022032042052062072082092102112122132142152162172186 unmodified lines225226227"""open-predico dashboard: backtest scores from the public open-predico/benchmark dataset.Runs in the browser with stlite (Streamlit on Pyodide, see index.html), so the Space is a freestatic one; `streamlit run app.py` works locally too."""import ioimport jsonimport sys8 unmodified linesPREFIX = "predictions/backtest/"TZ = "Europe/Madrid"ALPHA = 0.2COLOR = alt.Color("config:N", scale=alt.Scale(scheme="tableau10"), legend=alt.Legend(orient="bottom")20 unmodified linesreturn req.response.to_py().tobytes()@st.cache_data(ttl=3600)def load() -> pd.DataFrame:"""Per-step errors for every config and target, with local time columns."""tree = json.loads(fetch(f"{HF}/api/datasets/{REPO}/tree/main/{PREFIX.rstrip('/')}?recursive=true"))1 unmodified lineout = []for f in files:config, target = f.removeprefix(PREFIX).removesuffix(".parquet").split("/")df = pd.read_parquet(io.BytesIO(fetch(f"{HF}/datasets/{REPO}/resolve/main/{f}")))# Same formulas as src/openpredico/evaluation/metrics.py (copied, keep in sync).o, q10, q50, q90 = df.obs, df.q10, df.q50, df.q90df["se"] = (o - q50) ** 29 unmodified linesdf["day"] = local.tz_localize(None).normalize()df["hour"] = local.hourdf["weekday"] = local.dayofweekdf["config"], df["target"] = config, targetout.append(df.reset_index())return pd.concat(out, ignore_index=True)def daily(steps: pd.DataFrame) -> pd.DataFrame:"""Daily scores; a day with any missing truth is skipped, as Predico does."""g = steps.groupby(["target", "config", "day"])d = g.agg(se=("se", "mean"),winkler=("winkler", "mean"),4 unmodified linesreturn d[~d.pop("missing")].reset_index()steps = load()days = daily(steps)targets = sorted(days.target.unique())configs = sorted(days.config.unique())st.title("open-predico")st.caption(1 unmodified line"[Code](https://github.com/arnaud-vs/open-predico) · ""[Data](https://huggingface.co/datasets/open-predico/benchmark)")(tab,) = st.tabs(["Backtest"])with tab:st.markdown("Test year 1 Nov 2025 – 31 Oct 2026, forecast made at 14:00 Madrid on D-1. ""RMSE on q50, Winkler (α = 0.2) on q10/q90, per local day; lower is better. ""Days with any missing truth are skipped, like Predico.")st.subheader("Leaderboard")cols = st.columns(len(targets))for col, t in zip(cols, targets, strict=True):lb = (days[days.target == t].groupby("config").agg(rmse=("rmse", "mean"),winkler=("winkler", "mean"),coverage=("coverage", "mean"),days=("day", "count"),).sort_values("rmse"))col.markdown(f"**{t}**")col.dataframe(lb.style.format({"rmse": "{:.1f}", "winkler": "{:.1f}", "coverage": "{:.0%}"}),)st.subheader("By month")target = st.selectbox("Target", targets, key="month_target")monthly = (days[days.target == target].assign(month=lambda d: d.day.dt.to_period("M").dt.to_timestamp()).groupby(["config", "month"])[["rmse", "winkler"]].mean().reset_index())cols = st.columns(2)for col, metric in zip(cols, ["rmse", "winkler"], strict=True):col.altair_chart(alt.Chart(monthly, title=metric.upper()).mark_line(point=True).encode(x=alt.X("yearmonth(month):T", title=None),y=alt.Y(f"{metric}:Q", title=None),color=COLOR,tooltip=["config", "yearmonth(month):T", alt.Tooltip(f"{metric}:Q", format=".1f")],),)st.subheader("Paired comparison")c1, c2 = st.columns(2)a = c1.selectbox("Config A", configs, index=len(configs) - 1)b = c2.selectbox("Config B", configs, index=0)rows = []for t in targets:p = days[days.target == t].pivot(index="day", columns="config", values=["rmse", "winkler"])both = p.dropna()rows.append({"target": t,"days": len(both),"A wins RMSE": (both["rmse"][a] < both["rmse"][b]).mean(),"A wins Winkler": (both["winkler"][a] < both["winkler"][b]).mean(),})st.dataframe(pd.DataFrame(rows).set_index("target").style.format({"A wins RMSE": "{:.0%}", "A wins Winkler": "{:.0%}"}),)st.subheader("Absolute error of q50 by hour and weekday (Madrid time)")target = st.selectbox("Target", targets, key="hour_target")sel = steps[steps.target == target]cols = st.columns(2)for col, key, title in [(cols[0], "hour", "Hour of day"), (cols[1], "weekday", "Weekday")]:prof = sel.groupby(["config", key]).ae.mean().reset_index()if key == "weekday":prof["weekday"] = prof.weekday.map(dict(enumerate("Mon Tue Wed Thu Fri Sat Sun".split())))col.altair_chart(alt.Chart(prof, title=title).mark_line(point=True).encode(x=alt.X(f"{key}:O",title=None,sort="Mon Tue Wed Thu Fri Sat Sun".split() if key == "weekday" else None,),y=alt.Y("ae:Q", title="MAE"),color=COLOR,tooltip=["config", key, alt.Tooltip("ae:Q", format=".1f")],2 unmodified linesst.subheader("Day viewer")c1, c2 = st.columns(2)target = c1.selectbox("Target", targets, key="day_target")lo, hi = steps.day.min().date(), steps.day.max().date()date = c2.date_input("Day (Madrid)", value=hi, min_value=lo, max_value=hi)view = steps[(steps.target == target) & (steps.day == pd.Timestamp(date))].copy()view["time"] = view.time.dt.tz_convert(TZ).dt.tz_localize(None)cfgs = st.multiselect("Configs", configs, default=configs)view = view[view.config.isin(cfgs)]shown = days[(days.target == target) & (days.day == pd.Timestamp(date))]if shown.empty:st.caption("Truth incomplete on this day: not scored.")else:st.caption(" · ".join(f"{r.config}: RMSE {r.rmse:.1f}, Winkler {r.winkler:.1f}"for r in shown.itertuples()))base = alt.Chart(view).encode(x=alt.X("time:T", title=None))6 unmodified lines)st.altair_chart(band + q50 + obs)st.caption("Shaded: q10–q90 band; solid: q50; dashed grey: truth.")12345678910118 unmodified lines202122232425262728293031323334353637383920 unmodified lines60616263646566676869707172737475767778791 unmodified line818283848586879 unmodified lines9798991001011021031041051061071081091101114 unmodified lines1161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052061 unmodified line2082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413422 unmodified lines3453463473483493503513523533543553563573583593603613623633643653666 unmodified lines373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509"""open-predico dashboard: backtest scores and target data from open-predico/benchmark (public).Runs in the browser with stlite (Streamlit on Pyodide, see index.html), so the Space is a freestatic one; `streamlit run app.py` works locally too. Pyodide is slow: every file is fetched onceand cached, and plots get aggregated data."""import datetime as dtimport ioimport jsonimport sys8 unmodified linesPREFIX = "predictions/backtest/"TZ = "Europe/Madrid"ALPHA = 0.2BASELINE = "slot_climatology_28d"METRICS = {"rmse": "RMSE", "winkler": "Winkler"}WEEKDAYS = "Mon Tue Wed Thu Fri Sat Sun".split()# Model type from the config name prefix; anything else is an ML model.TYPES = {"slot_climatology": "baseline","persistence": "baseline","zero_inflated": "baseline","chronos": "foundation model","timesfm": "foundation model","timestral": "foundation model","t0": "foundation model","toto": "foundation model",}COLOR = alt.Color("config:N", scale=alt.Scale(scheme="tableau10"), legend=alt.Legend(orient="bottom")20 unmodified linesreturn req.response.to_py().tobytes()def parquet(path: str) -> pd.DataFrame:return pd.read_parquet(io.BytesIO(fetch(f"{HF}/datasets/{REPO}/resolve/main/{path}")))def model_type(config: str) -> str:return next((t for p, t in TYPES.items() if config.startswith(p)), "ML")# --- Backtest data ---------------------------------------------------------------------------@st.cache_resource(ttl=3600)def load_steps() -> pd.DataFrame:"""Per-step errors for every config folder under predictions/backtest/, with local time."""tree = json.loads(fetch(f"{HF}/api/datasets/{REPO}/tree/main/{PREFIX.rstrip('/')}?recursive=true"))1 unmodified lineout = []for f in files:config, target = f.removeprefix(PREFIX).removesuffix(".parquet").split("/")df = parquet(f)# Same formulas as src/openpredico/evaluation/metrics.py (copied, keep in sync).o, q10, q50, q90 = df.obs, df.q10, df.q50, df.q90df["se"] = (o - q50) ** 29 unmodified linesdf["day"] = local.tz_localize(None).normalize()df["hour"] = local.hourdf["weekday"] = local.dayofweekdf["config"], df["target"] = config, target.removeprefix("spain_mfrr_")out.append(df.reset_index())return pd.concat(out, ignore_index=True)@st.cache_resource(ttl=3600)def load_days() -> pd.DataFrame:"""Daily scores; a day with any missing truth is skipped, as Predico does."""g = load_steps().groupby(["target", "config", "day"])d = g.agg(se=("se", "mean"),winkler=("winkler", "mean"),4 unmodified linesreturn d[~d.pop("missing")].reset_index()def leaderboard(days: pd.DataFrame) -> pd.DataFrame:"""One row per config: raw and baseline-normalised scores per target, aggregate and rank.Normalised = mean daily score / baseline's mean daily score, on days both are scored.Score = geometric mean of the normalised RMSE and Winkler over both targets."""cols = {}for t, d in days.groupby("target"):p = d.pivot(index="day", columns="config", values=["rmse", "winkler", "coverage"])for m in METRICS:cols[f"{t} {m}"] = p[m].mean()if BASELINE in p[m]:both = p[m].dropna(subset=[BASELINE])cols[f"{t} {m} rel"] = both.mean() / both[BASELINE].mean()cols[f"{t} coverage"] = p["coverage"].mean()cols[f"{t} days"] = p["rmse"].count()lb = pd.DataFrame(cols)rel = lb.filter(like=" rel")lb.insert(0, "score", np.exp(np.log(rel).mean(axis=1, skipna=False)))lb.insert(0, "type", [model_type(c) for c in lb.index])lb.insert(0, "rank", lb.score.rank(method="min"))return lb.sort_values(["score", "rank"]).rename_axis("config").reset_index()def win_rates(days: pd.DataFrame, target: str, metric: str, order: list[str]) -> pd.DataFrame:"""Long frame: share of commonly scored days where row config A beats column config B."""p = days[days.target == target].pivot(index="day", columns="config", values=metric)rows = []for a in order:for b in order:both = p[[a, b]].dropna() if a != b else Nonerows.append({"A": a,"B": b,"win": (both[a] < both[b]).mean() if a != b and len(both) else np.nan,"days": len(both) if a != b else 0,})return pd.DataFrame(rows)# --- Target data -----------------------------------------------------------------------------@st.cache_resourcedef load_target() -> pd.DataFrame:"""v1/target.parquet in long form with local calendar columns."""df = parquet("v1/target.parquet")local = df.index.tz_convert(TZ)cal = pd.DataFrame({"time": local.tz_localize(None),"day": local.tz_localize(None).normalize(),"slot": local.strftime("%H:%M"),"weekday": local.dayofweek,"month": local.tz_localize(None).to_period("M").to_timestamp(),})out = []for col in df.columns:out.append(cal.assign(target=col.removeprefix("mfrr_"), value=df[col].to_numpy()))return pd.concat(out, ignore_index=True)@st.cache_resourcedef profile(target: str, key: str) -> pd.DataFrame:"""Mean and q10/q90 of the target by a calendar key."""v = load_target()g = v[v.target == target].groupby(key).valuereturn pd.DataFrame({"mean": g.mean(), "q10": g.quantile(0.1), "q90": g.quantile(0.9)}).reset_index()def band_chart(df: pd.DataFrame, x: alt.X, title: str) -> alt.LayerChart:base = alt.Chart(df, title=title).encode(x=x)band = base.mark_area(opacity=0.25).encode(y=alt.Y("q10:Q", title=None), y2="q90:Q")line = base.mark_line(point=len(df) < 40).encode(y="mean:Q", tooltip=[x.shorthand, alt.Tooltip("mean:Q", format=".1f")])return band + line# --- Page ------------------------------------------------------------------------------------st.title("open-predico")st.caption(1 unmodified line"[Code](https://github.com/arnaud-vs/open-predico) · ""[Data](https://huggingface.co/datasets/open-predico/benchmark)")tab_bt, tab_target = st.tabs(["Backtest", "Target data"])with tab_bt:steps, days = load_steps(), load_days()targets = sorted(days.target.unique())st.markdown("Test year 1 Nov 2025 – 31 Oct 2026, forecast made at 14:00 Madrid on D-1, scored per ""local day; lower is better. Days with any missing truth are skipped, like Predico.")st.subheader("Leaderboard")lb = leaderboard(days)order = lb.config.tolist()types = st.pills("Model type", sorted(lb.type.unique()), selection_mode="multi", default=None)absolute = st.toggle("Show absolute scores")shown = lb[lb.type.isin(types)] if types else lbkeep = ["rank", "config", "type", "score"]for t in targets:keep += [f"{t} rmse rel", f"{t} winkler rel", f"{t} coverage"]keep += [f"{t} rmse", f"{t} winkler", f"{t} days"] if absolute else []ratio = "Mean daily {} / baseline's, on days both are scored; < 1 beats the baseline."colcfg = {"rank": st.column_config.NumberColumn("Rank", format="%d"),"score": st.column_config.NumberColumn("Score",format="%.3f",help="Geometric mean of the four normalised scores (RMSE and Winkler, both targets).",),}for t in targets:colcfg |= {f"{t} rmse rel": st.column_config.NumberColumn(f"{t} RMSE", format="%.3f", help=ratio.format("RMSE of q50")),f"{t} winkler rel": st.column_config.NumberColumn(f"{t} Winkler", format="%.3f", help=ratio.format("Winkler score of q10/q90")),f"{t} coverage": st.column_config.NumberColumn(f"{t} coverage",format="percent",help="Share of quarter-hours inside q10–q90; ideal 80%.",),f"{t} rmse": st.column_config.NumberColumn(f"{t} RMSE abs", format="%.1f"),f"{t} winkler": st.column_config.NumberColumn(f"{t} Winkler abs", format="%.1f"),f"{t} days": st.column_config.NumberColumn(f"{t} days", format="%d"),}st.dataframe(shown[keep], column_config=colcfg, hide_index=True)with st.expander("Metrics"):st.markdown(f"""- **RMSE** (Predico's q50 score): `sqrt(mean_t (obs − q50)²)` over a local day.- **Winkler** (Predico's q10/q90 score, α = 0.2): `mean_t [(q90 − q10) + 10·max(0, q10 − obs)+ 10·max(0, obs − q90)]`. Rewards narrow intervals, penalises misses.- **Coverage**: share of quarter-hours with obs inside [q10, q90]; a calibrated model gets 80%.- **Normalised**: a config's mean daily score divided by the baseline `{BASELINE}` (= 1.0) onthe days both are scored. **Score** is the geometric mean of the four normalised values;**Rank** sorts by it.- **Type**: baseline, foundation model (pretrained, zero-shot), ML (trained here).""")st.subheader("Win rate")st.caption("Cell (row A, column B): share of days scored for both where A has the lower score. ""Read across a row: green = A usually wins.")target = st.radio("Target", targets, horizontal=True, key="win_target")cols = st.columns(2)for col, (m, label) in zip(cols, METRICS.items(), strict=True):w = win_rates(days, target, m, order)enc = {"x": alt.X("B:N", sort=order, title="B"),"y": alt.Y("A:N", sort=order, title="A"),}heat = (alt.Chart(w, title=label).mark_rect().encode(**enc,color=alt.Color("win:Q",scale=alt.Scale(scheme="redyellowgreen", domain=[0, 1]),legend=alt.Legend(format="%", title="A wins"),),tooltip=["A", "B", alt.Tooltip("win:Q", format=".0%"), "days"],))text = (alt.Chart(w).mark_text(color="black").encode(**enc, text=alt.Text("win:Q", format=".0%")))col.altair_chart(heat + text)st.subheader("By month")target = st.radio("Target", targets, horizontal=True, key="month_target")monthly = (days[days.target == target].assign(month=lambda d: d.day.dt.to_period("M").dt.to_timestamp()).groupby(["config", "month"])[list(METRICS)].mean().reset_index())cols = st.columns(2)for col, (m, label) in zip(cols, METRICS.items(), strict=True):col.altair_chart(alt.Chart(monthly, title=label).mark_line(point=True).encode(x=alt.X("yearmonth(month):T", title=None),y=alt.Y(f"{m}:Q", title=None),color=COLOR,tooltip=["config", "yearmonth(month):T", alt.Tooltip(f"{m}:Q", format=".1f")],),)st.subheader("Absolute error of q50 by hour and weekday (Madrid time)")target = st.radio("Target", targets, horizontal=True, key="hour_target")sel = steps[steps.target == target]cols = st.columns(2)for col, key, title in [(cols[0], "hour", "Hour of day"), (cols[1], "weekday", "Weekday")]:prof = sel.groupby(["config", key]).ae.mean().reset_index()if key == "weekday":prof["weekday"] = prof.weekday.map(dict(enumerate(WEEKDAYS)))col.altair_chart(alt.Chart(prof, title=title).mark_line(point=True).encode(x=alt.X(f"{key}:O", title=None, sort=WEEKDAYS if key == "weekday" else None),y=alt.Y("ae:Q", title="MAE"),color=COLOR,tooltip=["config", key, alt.Tooltip("ae:Q", format=".1f")],2 unmodified linesst.subheader("Day viewer")c1, c2 = st.columns(2)target = c1.radio("Target", targets, horizontal=True, key="day_target")lo, hi = steps.day.min().date(), steps.day.max().date()date = c2.date_input("Day (Madrid)", value=hi, min_value=lo, max_value=hi)cfgs = st.multiselect("Configs", order, default=order)view = steps[(steps.target == target) & (steps.day == pd.Timestamp(date)) & steps.config.isin(cfgs)].copy()view["time"] = view.time.dt.tz_convert(TZ).dt.tz_localize(None)scored = days[(days.target == target) & (days.day == pd.Timestamp(date))]if scored.empty:st.caption("Truth incomplete on this day: not scored.")else:st.caption(" · ".join(f"{r.config}: RMSE {r.rmse:.1f}, Winkler {r.winkler:.1f}"for r in scored.itertuples()))base = alt.Chart(view).encode(x=alt.X("time:T", title=None))6 unmodified lines)st.altair_chart(band + q50 + obs)st.caption("Shaded: q10–q90 band; solid: q50; dashed grey: truth.")with tab_target:tv = load_target()st.markdown("Truth series from `v1/target.parquet`: mFRR activated **energy** (net, MWh per ""quarter-hour, upward positive) and mFRR **price** (EUR/MWh), Spain, 15-min, ""10 Dec 2024 – 31 Oct 2026. Missing energy is filled with 0 (no activation); missing ""price stays empty. Times in Madrid local time.\n\n""- **Iberian blackout:** no data 28 Apr – 6 May 2025 (energy 0, price missing).\n""- **Regime shift:** prices rise from Jul 2026 (monthly mean ~100 → ~157 EUR/MWh through ""Oct 2026), so recent months look different from the rest of the history.")target = st.radio("Target", ["energy", "price"], horizontal=True, key="tgt")unit = "MWh" if target == "energy" else "EUR/MWh"v = tv[tv.target == target]st.subheader("Time series")c1, c2 = st.columns([1, 2])res = c1.radio("Resolution", ["Daily", "15-min"], horizontal=True)if res == "Daily":d = v.groupby("day").value.agg(["mean", "min", "max"]).reset_index()base = alt.Chart(d).encode(x=alt.X("day:T", title=None))chart = base.mark_area(opacity=0.2).encode(y=alt.Y("min:Q", title=unit), y2="max:Q") + base.mark_line().encode(y="mean:Q",tooltip=[alt.Tooltip("day:T"), alt.Tooltip("mean:Q", format=".1f"), "min", "max"],)st.caption("Daily mean (line) and min–max (band).")else:lo, hi = v.day.min().date(), v.day.max().date()rng = c2.date_input("Days (max 31)", value=(hi - dt.timedelta(days=13), hi), min_value=lo, max_value=hi)a, b = (rng[0], rng[-1]) if rng else (hi, hi)b = min(b, a + dt.timedelta(days=30))w = v[(v.day >= pd.Timestamp(a)) & (v.day <= pd.Timestamp(b))]chart = (alt.Chart(w).mark_line().encode(x=alt.X("time:T", title=None),y=alt.Y("value:Q", title=unit),tooltip=["time:T", alt.Tooltip("value:Q", format=".1f")],))st.altair_chart(chart.interactive(bind_y=False))st.subheader("Typical patterns")st.caption("Mean (line) and q10–q90 (band) over the whole history.")cols = st.columns(3)cols[0].altair_chart(band_chart(profile(target, "slot"),alt.X("slot:O", title=None, axis=alt.Axis(values=[f"{h:02d}:00" for h in range(0, 24, 3)])),"Quarter-hour of day",))wd = profile(target, "weekday").assign(weekday=lambda d: d.weekday.map(dict(enumerate(WEEKDAYS))))cols[1].altair_chart(band_chart(wd, alt.X("weekday:O", title=None, sort=WEEKDAYS), "Weekday"))cols[2].altair_chart(band_chart(profile(target, "month"), alt.X("yearmonth(month):T", title=None), "Month"))st.subheader("Distribution")x = v.value.dropna()stats = {"Mean": f"{x.mean():.1f}","Std": f"{x.std():.1f}","Exact zeros": f"{(x == 0).mean():.1%}","Negative": f"{(x < 0).mean():.1%}","Min / max": f"{x.min():.0f} / {x.max():.0f}",}for col, (k, s) in zip(st.columns(len(stats)), stats.items(), strict=True):col.metric(k, s)lo, hi = x.quantile([0.005, 0.995])counts, edges = np.histogram(x.clip(lo, hi), bins=80)hist = pd.DataFrame({"start": edges[:-1], "end": edges[1:], "count": counts})st.altair_chart(alt.Chart(hist).mark_bar().encode(x=alt.X("start:Q", bin="binned", title=unit),x2="end:Q",y=alt.Y("count:Q", title="Quarter-hours"),tooltip=[alt.Tooltip("start:Q", format=".1f"),alt.Tooltip("end:Q", format=".1f"),"count",],))st.caption("Values clipped to the 0.5–99.5% range for display (extremes pile up at the edges).")st.subheader("Missing values")kind = st.radio("Count per day", ["Missing", "Exact zeros"], horizontal=True)flag = v.value.isna() if kind == "Missing" else v.value.eq(0)per_day = flag.groupby(v.day).sum().rename("n").reset_index()per_day["month"] = per_day.day.dt.strftime("%Y-%m")per_day["dom"] = per_day.day.dt.dayst.altair_chart(alt.Chart(per_day).mark_rect().encode(x=alt.X("dom:O", title="Day of month"),y=alt.Y("month:O", title=None),color=alt.Color("n:Q", scale=alt.Scale(scheme="oranges"), title="Quarter-hours"),tooltip=[alt.Tooltip("day:T"), "n"],))st.caption(f"{int(flag.sum())} of {len(flag)} quarter-hours ({flag.mean():.1%}). Energy gaps were ""filled with 0 upstream, so for energy use 'Exact zeros' to see them.")st.subheader("Price vs energy")both = pd.DataFrame({t: tv[tv.target == t].value.to_numpy() for t in ["energy", "price"]}).dropna()sample = both.sample(min(5000, len(both)), random_state=0)st.altair_chart(alt.Chart(sample).mark_circle(size=8, opacity=0.3).encode(x=alt.X("energy:Q", title="Net mFRR energy (MWh)"),y=alt.Y("price:Q", title="mFRR price (EUR/MWh)"),tooltip=["energy", "price"],))st.caption("Random sample of 5000 quarter-hours.")
README.md+2-2
app.py+358-76