Spaces:
Runtime error
Runtime error
zhouziyu02 commited on
Commit ·
c29fb7f
1
Parent(s): c8b7238
Add TSFM Realworld Bench leaderboard
Browse files- README.md +9 -5
- app.py +93 -0
- requirements.txt +5 -0
- results/dataset_properties.csv +7 -0
- results/demo_foundation/all_results.csv +13 -0
- results/demo_foundation/config.json +10 -0
- results/seasonal_naive/all_results.csv +13 -0
- results/seasonal_naive/config.json +10 -0
- src/__init__.py +1 -0
- src/__pycache__/__init__.cpython-311.pyc +0 -0
- src/__pycache__/populate.cpython-311.pyc +0 -0
- src/__pycache__/utils.cpython-311.pyc +0 -0
- src/about.py +41 -0
- src/display/__init__.py +1 -0
- src/display/__pycache__/__init__.cpython-311.pyc +0 -0
- src/display/__pycache__/formatting.cpython-311.pyc +0 -0
- src/display/__pycache__/utils.cpython-311.pyc +0 -0
- src/display/css_html_js.py +5 -0
- src/display/formatting.py +8 -0
- src/display/utils.py +25 -0
- src/leaderboard/__init__.py +1 -0
- src/leaderboard/__pycache__/__init__.cpython-311.pyc +0 -0
- src/leaderboard/__pycache__/read_evals.cpython-311.pyc +0 -0
- src/leaderboard/read_evals.py +82 -0
- src/populate.py +8 -0
- src/utils.py +207 -0
README.md
CHANGED
|
@@ -1,13 +1,17 @@
|
|
| 1 |
---
|
| 2 |
title: TSFM Realworld Bench
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: '3.13'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: TSFM Realworld Bench
|
| 3 |
+
emoji: 📈
|
| 4 |
+
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.0
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: apache-2.0
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# TSFM Realworld Bench Leaderboard
|
| 14 |
+
|
| 15 |
+
Leaderboard for the **TSFM Realworld Benchmark** — evaluating time series foundation models on real-world multivariate forecasting tasks.
|
| 16 |
+
|
| 17 |
+
Results are submitted via pull request to the [TSFM_Bench](https://github.com/zhouziyu02/TSFM_Bench) repository.
|
app.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from gradio_leaderboard import ColumnFilter, Leaderboard, SelectColumns
|
| 4 |
+
|
| 5 |
+
from src.about import (
|
| 6 |
+
CITATION_BUTTON_LABEL,
|
| 7 |
+
CITATION_BUTTON_TEXT,
|
| 8 |
+
INTRODUCTION_TEXT,
|
| 9 |
+
LLM_BENCHMARKS_TEXT,
|
| 10 |
+
TITLE,
|
| 11 |
+
)
|
| 12 |
+
from src.display.css_html_js import custom_css
|
| 13 |
+
from src.display.utils import fields
|
| 14 |
+
from src.populate import get_model_info_df
|
| 15 |
+
from src.utils import get_grouped_dfs, get_merged_df, prepare_leaderboard_table
|
| 16 |
+
|
| 17 |
+
RESULTS_PATH = "results"
|
| 18 |
+
grouped = get_grouped_dfs(RESULTS_PATH)
|
| 19 |
+
model_info_df = get_model_info_df(RESULTS_PATH)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def init_leaderboard(
|
| 23 |
+
result_df: pd.DataFrame,
|
| 24 |
+
info_df: pd.DataFrame,
|
| 25 |
+
sort_col: str = "MASE_Rank",
|
| 26 |
+
):
|
| 27 |
+
if result_df is None or result_df.empty:
|
| 28 |
+
raise ValueError("Leaderboard dataframe is empty.")
|
| 29 |
+
|
| 30 |
+
column_specs = fields(None)
|
| 31 |
+
model_info_cols = [c.name for c in column_specs if c.displayed_by_default]
|
| 32 |
+
col_types = {c.name: c.type for c in column_specs}
|
| 33 |
+
|
| 34 |
+
merged = get_merged_df(result_df, info_df)
|
| 35 |
+
if "T" in merged.columns:
|
| 36 |
+
merged = merged[["T"] + [col for col in merged.columns if col != "T"]]
|
| 37 |
+
|
| 38 |
+
if sort_col in merged.columns:
|
| 39 |
+
merged = merged.sort_values(by=[sort_col])
|
| 40 |
+
|
| 41 |
+
datatypes = [col_types.get(col, "number") for col in merged.columns]
|
| 42 |
+
return Leaderboard(
|
| 43 |
+
value=merged,
|
| 44 |
+
datatype=datatypes,
|
| 45 |
+
select_columns=SelectColumns(
|
| 46 |
+
default_selection=list(result_df.columns) + model_info_cols,
|
| 47 |
+
cant_deselect=[c.name for c in column_specs if c.never_hidden],
|
| 48 |
+
label="Select columns",
|
| 49 |
+
),
|
| 50 |
+
hide_columns=[c.name for c in column_specs if c.hidden],
|
| 51 |
+
search_columns=["Model"],
|
| 52 |
+
filter_columns=[
|
| 53 |
+
ColumnFilter("Type", type="checkboxgroup", label="Model types"),
|
| 54 |
+
ColumnFilter("Test Leak.", type="checkboxgroup", label="Test Leak."),
|
| 55 |
+
ColumnFilter("Replication Code", type="checkboxgroup", label="Replication Code"),
|
| 56 |
+
],
|
| 57 |
+
column_widths=[30, 180] + [130 for _ in range(len(merged.columns) - 2)],
|
| 58 |
+
interactive=False,
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
overall_df = prepare_leaderboard_table(grouped["overall"])
|
| 63 |
+
domain_df = prepare_leaderboard_table(grouped["domain"], "domain")
|
| 64 |
+
frequency_df = prepare_leaderboard_table(grouped["frequency"], "frequency")
|
| 65 |
+
|
| 66 |
+
demo = gr.Blocks(css=custom_css)
|
| 67 |
+
with demo:
|
| 68 |
+
gr.HTML(TITLE)
|
| 69 |
+
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
| 70 |
+
|
| 71 |
+
with gr.Tabs(elem_classes="tab-buttons"):
|
| 72 |
+
with gr.TabItem("Overall"):
|
| 73 |
+
init_leaderboard(overall_df, model_info_df, sort_col="MASE_Rank")
|
| 74 |
+
|
| 75 |
+
with gr.TabItem("By Domain"):
|
| 76 |
+
init_leaderboard(domain_df, model_info_df)
|
| 77 |
+
|
| 78 |
+
with gr.TabItem("By Frequency"):
|
| 79 |
+
init_leaderboard(frequency_df, model_info_df)
|
| 80 |
+
|
| 81 |
+
with gr.TabItem("About"):
|
| 82 |
+
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
| 83 |
+
|
| 84 |
+
with gr.Row():
|
| 85 |
+
with gr.Accordion("Citation", open=False):
|
| 86 |
+
gr.Textbox(
|
| 87 |
+
value=CITATION_BUTTON_TEXT,
|
| 88 |
+
label=CITATION_BUTTON_LABEL,
|
| 89 |
+
lines=12,
|
| 90 |
+
show_copy_button=True,
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
demo.queue(default_concurrency_limit=20).launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==4.44.0
|
| 2 |
+
gradio_leaderboard==0.0.9
|
| 3 |
+
pandas
|
| 4 |
+
numpy
|
| 5 |
+
scipy
|
results/dataset_properties.csv
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
dataset,domain,frequency,num_variates
|
| 2 |
+
synthetic_energy,Energy,H,4
|
| 3 |
+
synthetic_finance,Econ/Fin,D,2
|
| 4 |
+
synthetic_healthcare,Healthcare,D,1
|
| 5 |
+
synthetic_retail,Sales,W,3
|
| 6 |
+
synthetic_transport,Transport,15T,5
|
| 7 |
+
synthetic_cloudops,Web/CloudOps,H,2
|
results/demo_foundation/all_results.csv
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
dataset,model,eval_metrics/MSE[mean],eval_metrics/MSE[0.5],eval_metrics/MAE[0.5],eval_metrics/MASE[0.5],eval_metrics/MAPE[0.5],eval_metrics/sMAPE[0.5],eval_metrics/MSIS,eval_metrics/RMSE[mean],eval_metrics/NRMSE[mean],eval_metrics/ND[0.5],eval_metrics/mean_weighted_sum_quantile_loss,domain,num_variates
|
| 2 |
+
synthetic_cloudops/H/short,Demo_Foundation,0.9484441768795722,0.9484441768795722,0.9939611037572226,1.9544640077490765,0.013103314200074564,0.013185751356258166,11.959342528826262,1.1315474531752623,0.01492807794287292,0.013112953228284572,0.009779597817226517,Web/CloudOps,2
|
| 3 |
+
synthetic_cloudops/H/medium,Demo_Foundation,44.819075470547105,44.819075470547105,6.807706328272821,13.385611844716413,0.08867233581220305,0.09257877306865481,342.502721561883,7.778544329451275,0.10327325597508717,0.09038374899799986,0.08250994917856377,Web/CloudOps,2
|
| 4 |
+
synthetic_energy/H/short,Demo_Foundation,0.9432282910514187,0.9432282910514187,0.9898946590450678,1.947071336223139,0.010444408367799645,0.010496861250305266,14.977514705664005,1.1284317404785347,0.011912227550697062,0.010449768476703645,0.00843810481653264,Energy,4
|
| 5 |
+
synthetic_energy/H/medium,Demo_Foundation,44.75317610021165,44.75317610021165,6.801061638012529,13.375673774996578,0.07422846437340501,0.07696293707705468,307.08265650277013,7.772823665521155,0.0859733433521586,0.07522491600545549,0.06741608964017566,Energy,4
|
| 6 |
+
synthetic_energy/H/long,Demo_Foundation,98.1563757844154,98.1563757844154,10.042938986778259,19.75138716724768,0.10570860847677263,0.11132441580818057,551.841802671887,11.51134689378097,0.12403242298742721,0.1082106262576423,0.10037404739845787,Energy,4
|
| 7 |
+
synthetic_finance/D/short,Demo_Foundation,0.340872160484375,0.340872160484375,0.5517136635099139,1.9523412290537816,0.023950215287083174,0.024199645748082033,13.77535362605325,0.6783637789961271,0.0296300964274947,0.02409817498563465,0.01883463598352619,Econ/Fin,2
|
| 8 |
+
synthetic_healthcare/D/short,Demo_Foundation,1.6291463192048774,1.6291463192048774,1.2133313255310059,3.251329713548875,0.03186831168020467,0.03215733223800848,33.64701694004747,1.4830197338291167,0.03899717571702146,0.0319055059250825,0.02578070760877386,Healthcare,1
|
| 9 |
+
synthetic_healthcare/D/medium,Demo_Foundation,20.904267278593395,20.904267278593395,4.6352615927696235,12.429531985625411,0.12175143359141603,0.12921982918004202,366.85470560802383,5.312321604167154,0.1430414381588789,0.12481068238644986,0.11703214755034728,Healthcare,1
|
| 10 |
+
synthetic_retail/W/short,Demo_Foundation,0.2435628929274714,0.2435628929274714,0.46023838834762565,1.628056010173888,0.060150004784169084,0.060644684722926834,32.665706742962556,0.5734194847161077,0.07459298761744944,0.05986988115704848,0.052464975171849004,Sales,3
|
| 11 |
+
synthetic_transport/15T/short,Demo_Foundation,5.1470709532532215,5.1470709532532215,2.591809342806156,1.3498925077539734,0.02281783112929364,0.023019212182647512,4.714454848209407,2.636009443627213,0.02319000866694819,0.022801163048963596,0.015037630968304936,Transport,5
|
| 12 |
+
synthetic_transport/15T/medium,Demo_Foundation,54.907992334692004,54.907992334692004,7.775680832898617,4.049800284767568,0.06983880451833344,0.0721045885121056,85.05263573058745,8.609633537603921,0.07804941894152942,0.07048933827808684,0.06211227640099275,Transport,5
|
| 13 |
+
synthetic_transport/15T/long,Demo_Foundation,114.32069811287074,114.32069811287074,11.060530899810791,5.76069688019541,0.09643010440578481,0.10090190811537968,151.21758896689101,12.423081037020387,0.11022139545445406,0.09813243160946569,0.08988387345190472,Transport,5
|
results/demo_foundation/config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "Demo_Foundation",
|
| 3 |
+
"model_type": "pretrained",
|
| 4 |
+
"model_dtype": "float32",
|
| 5 |
+
"model_link": "https://huggingface.co/ziyuzhou02/TSFM-Realworld-Bench",
|
| 6 |
+
"code_link": "https://github.com/zhouziyu02/TSFM_Bench/blob/main/scripts/run_demo_eval.py",
|
| 7 |
+
"org": "Demo Lab",
|
| 8 |
+
"testdata_leakage": "No",
|
| 9 |
+
"replication_code_available": "Yes"
|
| 10 |
+
}
|
results/seasonal_naive/all_results.csv
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
dataset,model,eval_metrics/MSE[mean],eval_metrics/MSE[0.5],eval_metrics/MAE[0.5],eval_metrics/MASE[0.5],eval_metrics/MAPE[0.5],eval_metrics/sMAPE[0.5],eval_metrics/MSIS,eval_metrics/RMSE[mean],eval_metrics/NRMSE[mean],eval_metrics/ND[0.5],eval_metrics/mean_weighted_sum_quantile_loss,domain,num_variates
|
| 2 |
+
synthetic_cloudops/H/short,Seasonal_Naive,0.7025512421330163,0.7025512421330163,0.7362674842646093,1.4477511168511676,0.009706158666721918,0.009767223226857937,8.85877224357501,0.8381832986483424,0.011057835513239248,0.00971329868761829,0.007244146531278948,Web/CloudOps,2
|
| 3 |
+
synthetic_cloudops/H/medium,Seasonal_Naive,33.199315163368226,33.199315163368226,5.042745428350237,9.915268033123269,0.06568321171274301,0.06857686893974435,253.70571967546886,5.761884688482426,0.07649870812969421,0.06695092518370366,0.06111848087301028,Web/CloudOps,2
|
| 4 |
+
synthetic_energy/H/short,Seasonal_Naive,0.6986876230010508,0.6986876230010508,0.7332553029963464,1.4422750638689918,0.00773659879096271,0.007775452778003927,11.094455337528892,0.8358753633174331,0.00882387225977561,0.00774056924200278,0.006250448012246424,Energy,4
|
| 5 |
+
synthetic_energy/H/medium,Seasonal_Naive,33.150500814971586,33.150500814971586,5.037823435564836,9.907906499997463,0.05498404768400379,0.05700958302004058,227.46863444649642,5.7576471596453,0.06368395803863605,0.05572216000404112,0.049937844177907996,Energy,4
|
| 6 |
+
synthetic_energy/H/long,Seasonal_Naive,72.70842650697436,72.70842650697436,7.4392140642801925,14.630657160924207,0.07830267294575755,0.08246253022828198,408.7717056828792,8.52692362502294,0.09187586887957572,0.08015601945010545,0.07435114622107997,Energy,4
|
| 7 |
+
synthetic_finance/D/short,Seasonal_Naive,0.25249789665509265,0.25249789665509265,0.4086767877851214,1.4461786881879863,0.017740900212654287,0.017925663517097897,10.203965648928333,0.5024916881452793,0.021948219575922044,0.01785049998935909,0.013951582210019405,Econ/Fin,2
|
| 8 |
+
synthetic_healthcare/D/short,Seasonal_Naive,1.2067750512628719,1.2067750512628719,0.8987639448377821,2.408392380406574,0.02360615680015168,0.02382024610222859,24.923716251887015,1.098533136169716,0.028886796827423317,0.023633708092653742,0.019096820450943675,Healthcare,1
|
| 9 |
+
synthetic_healthcare/D/medium,Seasonal_Naive,15.484642428587698,15.484642428587698,3.4335271057552763,9.207060730092895,0.09018624710475268,0.09571839198521635,271.7442263763139,3.9350530401238175,0.10595662085842886,0.09245235732329624,0.08669047966692395,Healthcare,1
|
| 10 |
+
synthetic_retail/W/short,Seasonal_Naive,0.1804169577240529,0.1804169577240529,0.34091732470194497,1.2059674149436206,0.04455555909938458,0.044921988683649564,24.19681980960189,0.4247551738637834,0.055254064901814476,0.04434806011633226,0.03886294457174005,Sales,3
|
| 11 |
+
synthetic_transport/15T/short,Seasonal_Naive,3.8126451505579415,3.8126451505579415,1.9198587724490044,0.9999203761140545,0.016902097132810153,0.017051268283442698,3.492188776451412,1.9525995878720095,0.01717778419773941,0.016889750406639755,0.011138985902448113,Transport,5
|
| 12 |
+
synthetic_transport/15T/medium,Seasonal_Naive,40.67258691458667,40.67258691458667,5.759763579924901,2.999852062790791,0.05173244779135817,0.05341080630526347,63.00195239302774,6.377506324151052,0.05781438440113298,0.05221432465043479,0.046009093630365004,Transport,5
|
| 13 |
+
synthetic_transport/15T/long,Seasonal_Naive,84.68199860212647,84.68199860212647,8.192985851711697,4.267182874218822,0.071429706967248,0.07474215415954054,112.0130288643637,9.20228224964473,0.08164547811441045,0.07269069008108577,0.06658064700141092,Transport,5
|
results/seasonal_naive/config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "Seasonal_Naive",
|
| 3 |
+
"model_type": "statistical",
|
| 4 |
+
"model_dtype": "float32",
|
| 5 |
+
"model_link": "https://github.com/zhouziyu02/TSFM_Bench",
|
| 6 |
+
"code_link": "https://github.com/zhouziyu02/TSFM_Bench/blob/main/scripts/run_demo_eval.py",
|
| 7 |
+
"org": "TSFM-Realworld-Bench",
|
| 8 |
+
"testdata_leakage": "No",
|
| 9 |
+
"replication_code_available": "Yes"
|
| 10 |
+
}
|
src/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
src/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (165 Bytes). View file
|
|
|
src/__pycache__/populate.cpython-311.pyc
ADDED
|
Binary file (893 Bytes). View file
|
|
|
src/__pycache__/utils.cpython-311.pyc
ADDED
|
Binary file (11.7 kB). View file
|
|
|
src/about.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
TITLE = """ TSFM Realworld Bench Leaderboard """
|
| 2 |
+
|
| 3 |
+
INTRODUCTION_TEXT = """
|
| 4 |
+
**TSFM Realworld Bench** evaluates time series foundation models on diverse real-world
|
| 5 |
+
multivariate forecasting tasks. Metrics and evaluation protocol follow
|
| 6 |
+
[GIFT-Eval](https://huggingface.co/spaces/Salesforce/GIFT-Eval): scores are normalized
|
| 7 |
+
by Seasonal Naive and aggregated with geometric mean. Primary ranking uses **CRPS_Rank**.
|
| 8 |
+
|
| 9 |
+
Submit results by opening a PR to the benchmark repository with `all_results.csv` and
|
| 10 |
+
`config.json` under `results/<MODEL_NAME>/`.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
LLM_BENCHMARKS_TEXT = """
|
| 14 |
+
## How to participate
|
| 15 |
+
|
| 16 |
+
1. Clone [TSFM_Bench](https://github.com/zhouziyu02/TSFM_Bench)
|
| 17 |
+
2. Implement your model against the streaming data interface (`tsfm_bench.data`)
|
| 18 |
+
3. Run evaluation and write `results/<MODEL_NAME>/all_results.csv`
|
| 19 |
+
4. Open a pull request; results sync to this leaderboard
|
| 20 |
+
|
| 21 |
+
## Metrics
|
| 22 |
+
|
| 23 |
+
- **MASE** — Mean Absolute Scaled Error (normalized)
|
| 24 |
+
- **CRPS** — Mean Weighted Sum Quantile Loss (probabilistic forecast quality)
|
| 25 |
+
- **CRPS_Rank** / **MASE_Rank** — average per-dataset rank (lower is better)
|
| 26 |
+
|
| 27 |
+
## Data interface
|
| 28 |
+
|
| 29 |
+
Real datasets plug in via `TimeSeriesDataSource.stream()`. The current demo uses
|
| 30 |
+
synthetic multivariate series to validate the end-to-end pipeline.
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
CITATION_BUTTON_LABEL = "Copy citation"
|
| 34 |
+
CITATION_BUTTON_TEXT = r"""
|
| 35 |
+
@misc{tsfm_realworld_bench,
|
| 36 |
+
title={TSFM Realworld Bench: A Benchmark for Time Series Foundation Models},
|
| 37 |
+
author={TSFM Realworld Bench Team},
|
| 38 |
+
year={2026},
|
| 39 |
+
howpublished={\url{https://huggingface.co/spaces/ziyuzhou02/TSFM-Realworld-Bench}}
|
| 40 |
+
}
|
| 41 |
+
"""
|
src/display/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
src/display/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (173 Bytes). View file
|
|
|
src/display/__pycache__/formatting.cpython-311.pyc
ADDED
|
Binary file (600 Bytes). View file
|
|
|
src/display/__pycache__/utils.cpython-311.pyc
ADDED
|
Binary file (1.89 kB). View file
|
|
|
src/display/css_html_js.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
custom_css = """
|
| 2 |
+
.markdown-text { font-size: 16px !important; }
|
| 3 |
+
.tab-buttons button { font-size: 20px; }
|
| 4 |
+
#leaderboard-table { margin-top: 15px; }
|
| 5 |
+
"""
|
src/display/formatting.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def model_hyperlink(model_link: str, code_link: str, model_name: str) -> str:
|
| 2 |
+
if not model_link:
|
| 3 |
+
return model_name
|
| 4 |
+
model_url = f"[{model_name}]({model_link})"
|
| 5 |
+
if not code_link:
|
| 6 |
+
return model_url
|
| 7 |
+
code_url = f"[code]({code_link})"
|
| 8 |
+
return f"{model_url} ({code_url})"
|
src/display/utils.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
@dataclass(frozen=True)
|
| 5 |
+
class ColumnSpec:
|
| 6 |
+
name: str
|
| 7 |
+
type: str
|
| 8 |
+
displayed_by_default: bool
|
| 9 |
+
hidden: bool = False
|
| 10 |
+
never_hidden: bool = False
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
MODEL_INFO_COLUMNS = [
|
| 14 |
+
ColumnSpec("T", "str", True, never_hidden=True),
|
| 15 |
+
ColumnSpec("Model", "markdown", True, never_hidden=True),
|
| 16 |
+
ColumnSpec("Type", "str", False, hidden=True),
|
| 17 |
+
ColumnSpec("Precision", "str", False, hidden=True),
|
| 18 |
+
ColumnSpec("Organization", "str", True),
|
| 19 |
+
ColumnSpec("Test Leak.", "str", True),
|
| 20 |
+
ColumnSpec("Replication Code", "str", True),
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def fields(_cls):
|
| 25 |
+
return MODEL_INFO_COLUMNS
|
src/leaderboard/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
src/leaderboard/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (177 Bytes). View file
|
|
|
src/leaderboard/__pycache__/read_evals.cpython-311.pyc
ADDED
|
Binary file (4.85 kB). View file
|
|
|
src/leaderboard/read_evals.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
from dataclasses import dataclass
|
| 4 |
+
from enum import Enum
|
| 5 |
+
|
| 6 |
+
from src.display.formatting import model_hyperlink
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class ModelType(Enum):
|
| 10 |
+
PT = ("🟢", "pretrained")
|
| 11 |
+
ZT = ("🔴", "zero-shot")
|
| 12 |
+
FT = ("🟣", "fine-tuned")
|
| 13 |
+
AG = ("🟡", "agentic")
|
| 14 |
+
DL = ("🔷", "deep-learning")
|
| 15 |
+
ST = ("🔶", "statistical")
|
| 16 |
+
Unknown = ("?", "")
|
| 17 |
+
|
| 18 |
+
def __init__(self, symbol: str, label: str):
|
| 19 |
+
self.symbol = symbol
|
| 20 |
+
self.label = label
|
| 21 |
+
|
| 22 |
+
@staticmethod
|
| 23 |
+
def from_str(model_type: str) -> "ModelType":
|
| 24 |
+
mapping = {
|
| 25 |
+
"fine-tuned": ModelType.FT,
|
| 26 |
+
"pretrained": ModelType.PT,
|
| 27 |
+
"zero-shot": ModelType.ZT,
|
| 28 |
+
"agentic": ModelType.AG,
|
| 29 |
+
"deep-learning": ModelType.DL,
|
| 30 |
+
"statistical": ModelType.ST,
|
| 31 |
+
}
|
| 32 |
+
return mapping.get(model_type, ModelType.Unknown)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
@dataclass
|
| 36 |
+
class ModelConfig:
|
| 37 |
+
model: str
|
| 38 |
+
model_link: str = ""
|
| 39 |
+
model_type: ModelType = ModelType.Unknown
|
| 40 |
+
code_link: str = ""
|
| 41 |
+
precision: str = "?"
|
| 42 |
+
org: str = ""
|
| 43 |
+
testdata_leakage: str = "N/A"
|
| 44 |
+
replication_code_available: str = "N/A"
|
| 45 |
+
|
| 46 |
+
@classmethod
|
| 47 |
+
def init_from_json_file(cls, json_filepath: str) -> "ModelConfig":
|
| 48 |
+
with open(json_filepath) as fp:
|
| 49 |
+
data = json.load(fp)
|
| 50 |
+
return cls(
|
| 51 |
+
model=data.get("model", ""),
|
| 52 |
+
model_link=data.get("model_link", ""),
|
| 53 |
+
model_type=ModelType.from_str(data.get("model_type", "")),
|
| 54 |
+
code_link=data.get("code_link", ""),
|
| 55 |
+
precision=data.get("model_dtype", "?"),
|
| 56 |
+
org=data.get("org", ""),
|
| 57 |
+
testdata_leakage=data.get("testdata_leakage", "N/A"),
|
| 58 |
+
replication_code_available=data.get("replication_code_available", "N/A"),
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
def to_dict(self) -> dict:
|
| 62 |
+
return {
|
| 63 |
+
"model": self.model,
|
| 64 |
+
"model_w_link": model_hyperlink(self.model_link, self.code_link, self.model),
|
| 65 |
+
"Precision": self.precision,
|
| 66 |
+
"Type": self.model_type.label,
|
| 67 |
+
"T": self.model_type.symbol,
|
| 68 |
+
"Organization": self.org,
|
| 69 |
+
"Test Leak.": self.testdata_leakage,
|
| 70 |
+
"Replication Code": self.replication_code_available,
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def get_model_info(results_path: str) -> list[ModelConfig]:
|
| 75 |
+
model_infos: dict[str, ModelConfig] = {}
|
| 76 |
+
for root, _, files in os.walk(results_path):
|
| 77 |
+
for file in files:
|
| 78 |
+
if file != "config.json":
|
| 79 |
+
continue
|
| 80 |
+
model_info = ModelConfig.init_from_json_file(os.path.join(root, file))
|
| 81 |
+
model_infos[model_info.model] = model_info
|
| 82 |
+
return list(model_infos.values())
|
src/populate.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
|
| 3 |
+
from src.leaderboard.read_evals import get_model_info
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def get_model_info_df(results_path: str) -> pd.DataFrame:
|
| 7 |
+
records = [info.to_dict() for info in get_model_info(results_path)]
|
| 8 |
+
return pd.DataFrame.from_records(records)
|
src/utils.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import re
|
| 3 |
+
|
| 4 |
+
import pandas as pd
|
| 5 |
+
from scipy import stats
|
| 6 |
+
|
| 7 |
+
from src.leaderboard.read_evals import get_model_info
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
METRIC_COLUMNS = [
|
| 11 |
+
"eval_metrics/MSE[mean]",
|
| 12 |
+
"eval_metrics/MSE[0.5]",
|
| 13 |
+
"eval_metrics/MAE[0.5]",
|
| 14 |
+
"eval_metrics/MASE[0.5]",
|
| 15 |
+
"eval_metrics/MAPE[0.5]",
|
| 16 |
+
"eval_metrics/sMAPE[0.5]",
|
| 17 |
+
"eval_metrics/MSIS",
|
| 18 |
+
"eval_metrics/RMSE[mean]",
|
| 19 |
+
"eval_metrics/NRMSE[mean]",
|
| 20 |
+
"eval_metrics/ND[0.5]",
|
| 21 |
+
"eval_metrics/mean_weighted_sum_quantile_loss",
|
| 22 |
+
]
|
| 23 |
+
RANKING_METRIC = "eval_metrics/mean_weighted_sum_quantile_loss"
|
| 24 |
+
MASE_RANKING_METRIC = "eval_metrics/MASE[0.5]"
|
| 25 |
+
METRIC_CHOICES = [MASE_RANKING_METRIC, RANKING_METRIC]
|
| 26 |
+
|
| 27 |
+
FREQ_LABELS = {
|
| 28 |
+
"T": "Minutely",
|
| 29 |
+
"H": "Hourly",
|
| 30 |
+
"D": "Daily",
|
| 31 |
+
"W": "Weekly",
|
| 32 |
+
"M": "Monthly",
|
| 33 |
+
"Q": "Quarterly",
|
| 34 |
+
"Y": "Yearly",
|
| 35 |
+
"A": "Yearly",
|
| 36 |
+
"S": "Secondly",
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def format_number(value):
|
| 41 |
+
if isinstance(value, (int, float)):
|
| 42 |
+
if abs(value) >= 10**2:
|
| 43 |
+
return f"{value:.1e}"
|
| 44 |
+
return f"{value:.3f}"
|
| 45 |
+
return value
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def format_df(df: pd.DataFrame) -> pd.DataFrame:
|
| 49 |
+
formatted = df.copy()
|
| 50 |
+
for col in formatted.columns:
|
| 51 |
+
formatted[col] = formatted[col].map(format_number)
|
| 52 |
+
if len(formatted.columns) > 1:
|
| 53 |
+
formatted.iloc[:, 1:] = formatted.iloc[:, 1:].astype(float)
|
| 54 |
+
return formatted
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def rename_metrics(df: pd.DataFrame) -> pd.DataFrame:
|
| 58 |
+
return df.rename(
|
| 59 |
+
columns={
|
| 60 |
+
"eval_metrics/MASE[0.5]": "MASE",
|
| 61 |
+
"eval_metrics/mean_weighted_sum_quantile_loss": "CRPS",
|
| 62 |
+
"rank": "CRPS_Rank",
|
| 63 |
+
"Rank_MASE": "MASE_Rank",
|
| 64 |
+
}
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def unify_freq(df: pd.DataFrame) -> pd.DataFrame:
|
| 69 |
+
df = df.copy()
|
| 70 |
+
df["frequency"] = df["frequency"].str.replace(r"\d+", "", regex=True)
|
| 71 |
+
df["frequency"] = df["frequency"].str.split("-").str[0]
|
| 72 |
+
df["frequency"] = df["frequency"].replace(FREQ_LABELS)
|
| 73 |
+
return df
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def pivot_grouped_df(df: pd.DataFrame, group_col: str) -> pd.DataFrame:
|
| 77 |
+
if group_col == "univariate":
|
| 78 |
+
df = df.copy()
|
| 79 |
+
df["univariate"] = df["univariate"].replace({True: "univariate", False: "multivariate"})
|
| 80 |
+
group_col = "variate_type"
|
| 81 |
+
|
| 82 |
+
melted = pd.melt(
|
| 83 |
+
df.reset_index(),
|
| 84 |
+
id_vars=[group_col, "model"],
|
| 85 |
+
var_name="metric",
|
| 86 |
+
value_name="value",
|
| 87 |
+
)
|
| 88 |
+
melted["metric"] = melted["metric"].replace(
|
| 89 |
+
{
|
| 90 |
+
"eval_metrics/MASE[0.5]": "MASE",
|
| 91 |
+
"eval_metrics/mean_weighted_sum_quantile_loss": "CRPS",
|
| 92 |
+
"rank": "CRPS_Rank",
|
| 93 |
+
}
|
| 94 |
+
)
|
| 95 |
+
pivoted = melted.pivot_table(
|
| 96 |
+
index="model", columns=[group_col, "metric"], values="value"
|
| 97 |
+
)
|
| 98 |
+
pivoted.columns = [f"{group} ({metric})" for group, metric in pivoted.columns]
|
| 99 |
+
return format_df(pivoted.reset_index())
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def standardize_df(df: pd.DataFrame) -> pd.DataFrame:
|
| 103 |
+
df = df.copy()
|
| 104 |
+
for metric in METRIC_COLUMNS:
|
| 105 |
+
df[metric] = pd.to_numeric(df[metric], errors="coerce")
|
| 106 |
+
df[metric] = df[metric].fillna(df[metric].mean())
|
| 107 |
+
|
| 108 |
+
baseline_name = "Seasonal_Naive"
|
| 109 |
+
if baseline_name not in set(df["model"]):
|
| 110 |
+
return df
|
| 111 |
+
|
| 112 |
+
for _, group in df.groupby(["dataset", "term_length", "frequency"]):
|
| 113 |
+
baseline = group[group["model"] == baseline_name]
|
| 114 |
+
if baseline.empty:
|
| 115 |
+
continue
|
| 116 |
+
idx = baseline.index[0]
|
| 117 |
+
for metric in METRIC_COLUMNS:
|
| 118 |
+
denom = baseline.at[idx, metric]
|
| 119 |
+
if denom and denom != 0:
|
| 120 |
+
df.loc[group.index, metric] = df.loc[group.index, metric] / denom
|
| 121 |
+
return df
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def group_by(df: pd.DataFrame, col_name: str) -> pd.DataFrame:
|
| 125 |
+
grouped = df.groupby([col_name, "model"])[METRIC_CHOICES].agg(stats.gmean)
|
| 126 |
+
grouped_rank = df.groupby([col_name, "model"])[["rank"]].mean()
|
| 127 |
+
return pd.concat([grouped, grouped_rank], axis=1)
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def load_all_results(root_dir: str = "results") -> pd.DataFrame:
|
| 131 |
+
frames = []
|
| 132 |
+
for subdir, _, files in os.walk(root_dir):
|
| 133 |
+
for file in files:
|
| 134 |
+
if file != "all_results.csv":
|
| 135 |
+
continue
|
| 136 |
+
frames.append(pd.read_csv(os.path.join(subdir, file)))
|
| 137 |
+
if not frames:
|
| 138 |
+
raise FileNotFoundError(f"No all_results.csv found under {root_dir}")
|
| 139 |
+
df = pd.concat(frames, ignore_index=True)
|
| 140 |
+
df = df.sort_values(by=["model", "dataset"]).reset_index(drop=True)
|
| 141 |
+
df[["dataset", "frequency", "term_length"]] = df["dataset"].str.split("/", expand=True)
|
| 142 |
+
return df
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def enrich_with_properties(df: pd.DataFrame, ds_properties_path: str) -> pd.DataFrame:
|
| 146 |
+
props = pd.read_csv(ds_properties_path)
|
| 147 |
+
props["dataset"] = props["dataset"].str.lower().str.replace(" ", "_")
|
| 148 |
+
props["dataset"] = props["dataset"].str.replace("-", "_")
|
| 149 |
+
props["dataset"] = props["dataset"].apply(lambda x: re.sub("_+", "_", x).strip("_"))
|
| 150 |
+
props_map = props.set_index("dataset").T.to_dict()
|
| 151 |
+
|
| 152 |
+
for dataset_key, values in props_map.items():
|
| 153 |
+
for key, value in values.items():
|
| 154 |
+
if key == "frequency" and df.loc[df["dataset"] == dataset_key, "frequency"].notna().all():
|
| 155 |
+
continue
|
| 156 |
+
df.loc[df["dataset"] == dataset_key, key] = value
|
| 157 |
+
return unify_freq(df)
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def get_grouped_dfs(
|
| 161 |
+
root_dir: str = "results",
|
| 162 |
+
ds_properties: str = "results/dataset_properties.csv",
|
| 163 |
+
) -> dict[str, pd.DataFrame]:
|
| 164 |
+
df = load_all_results(root_dir)
|
| 165 |
+
df = enrich_with_properties(df, ds_properties)
|
| 166 |
+
df = standardize_df(df)
|
| 167 |
+
|
| 168 |
+
df["rank"] = df.groupby(["dataset", "term_length", "frequency"])[RANKING_METRIC].rank(
|
| 169 |
+
method="first", ascending=True
|
| 170 |
+
)
|
| 171 |
+
df["Rank_MASE"] = df.groupby(["dataset", "term_length", "frequency"])[
|
| 172 |
+
MASE_RANKING_METRIC
|
| 173 |
+
].rank(method="first", ascending=True)
|
| 174 |
+
|
| 175 |
+
overall = df.groupby(["model"])[METRIC_CHOICES].agg(stats.gmean)
|
| 176 |
+
overall_rank = df.groupby(["model"])[["rank", "Rank_MASE"]].mean()
|
| 177 |
+
overall = pd.concat([overall, overall_rank], axis=1)
|
| 178 |
+
overall = overall[
|
| 179 |
+
[
|
| 180 |
+
"eval_metrics/MASE[0.5]",
|
| 181 |
+
"Rank_MASE",
|
| 182 |
+
"eval_metrics/mean_weighted_sum_quantile_loss",
|
| 183 |
+
"rank",
|
| 184 |
+
]
|
| 185 |
+
]
|
| 186 |
+
|
| 187 |
+
grouped = {
|
| 188 |
+
"overall": overall,
|
| 189 |
+
"domain": group_by(df, "domain"),
|
| 190 |
+
"frequency": group_by(df, "frequency"),
|
| 191 |
+
}
|
| 192 |
+
return grouped
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def get_merged_df(result_df: pd.DataFrame, model_info_df: pd.DataFrame) -> pd.DataFrame:
|
| 196 |
+
merged = pd.merge(model_info_df, result_df, left_on="model", right_on="model", how="inner")
|
| 197 |
+
merged = merged.drop(columns=["model"])
|
| 198 |
+
merged = merged.rename(columns={"model_w_link": "Model"})
|
| 199 |
+
return merged
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def prepare_leaderboard_table(grouped_df: pd.DataFrame, group_col: str | None = None) -> pd.DataFrame:
|
| 203 |
+
if group_col is None:
|
| 204 |
+
table = rename_metrics(grouped_df.reset_index())
|
| 205 |
+
table = format_df(table)
|
| 206 |
+
return table.sort_values(by=["MASE_Rank"])
|
| 207 |
+
return pivot_grouped_df(grouped_df, group_col)
|