attila-balint-kul commited on
Commit
23e3734
1 Parent(s): 2429cdc

Updated sorting of performance page

Browse files
Files changed (1) hide show
  1. components.py +49 -14
components.py CHANGED
@@ -54,13 +54,15 @@ def model_selector(models: list[str]) -> set[str]:
54
 
55
 
56
  def overview_view(data):
57
- st.markdown("""
 
58
  [EnFoBench](https://github.com/attila-balint-kul/energy-forecast-benchmark-toolkit)
59
  is a community driven benchmarking framework for energy forecasting models.
60
 
61
  This dashboard presents the results of the electricity demand forecasting usecase. All models were cross-validated
62
  on **365 days** of day ahead forecasting horizon *(10AM until midnight of the next day)*.
63
- """)
 
64
 
65
  st.divider()
66
  st.markdown("## Leaderboard")
@@ -69,20 +71,34 @@ def overview_view(data):
69
 
70
  left, middle, right = st.columns(3)
71
  with left:
72
- best_models_mae = leaderboard.sort_values("MAE.mean", ascending=False).head(10).sort_values("MAE.mean")
73
- fig = px.bar(best_models_mae, x="MAE.mean", y=best_models_mae.index)
74
- fig.update_layout(title="Top 10 models by MAE", xaxis_title="", yaxis_title="Model")
 
 
 
 
 
 
75
  st.plotly_chart(fig, use_container_width=True)
76
 
77
  with middle:
78
- best_models_mae = leaderboard.sort_values("RMSE.mean", ascending=False).head(10).sort_values("RMSE.mean")
79
- fig = px.bar(best_models_mae, x="RMSE.mean", y=best_models_mae.index)
 
 
 
 
80
  fig.update_layout(title="Top 10 models by RMSE", xaxis_title="", yaxis_title="")
81
  st.plotly_chart(fig, use_container_width=True)
82
 
83
  with right:
84
- best_models_mae = leaderboard.sort_values("rMAE.mean", ascending=False).head(10).sort_values("rMAE.mean")
85
- fig = px.bar(best_models_mae, x="rMAE.mean", y=best_models_mae.index)
 
 
 
 
86
  fig.update_layout(title="Top 10 models by rMAE", xaxis_title="", yaxis_title="")
87
  st.plotly_chart(fig, use_container_width=True)
88
 
@@ -222,8 +238,18 @@ def performance_view(data: pd.DataFrame, models_to_plot: set[str]):
222
  "Aggregation", ["min", "mean", "median", "max", "std"], index=1
223
  )
224
  st.markdown(f"#### {aggregation.capitalize()} {metric} per building")
 
 
 
 
 
 
 
 
 
 
225
  fig = px.box(
226
- data_to_plot,
227
  x=f"{metric}.{aggregation}",
228
  y="model",
229
  color="model",
@@ -283,7 +309,9 @@ def performance_view(data: pd.DataFrame, models_to_plot: set[str]):
283
  key="table_aggregation",
284
  )
285
 
286
- metrics_table = data_to_plot.groupby(["model"]).agg(aggregation, numeric_only=True)[
 
 
287
  [
288
  f"{metric}.min",
289
  f"{metric}.mean",
@@ -302,15 +330,22 @@ def performance_view(data: pd.DataFrame, models_to_plot: set[str]):
302
  return styler
303
 
304
  st.markdown(f"#### {aggregation.capitalize()} {metric} stats per model")
305
- styled_table = metrics_table.style.pipe(custom_table)
306
  st.dataframe(styled_table, use_container_width=True)
307
 
308
- metrics_table = (
309
  data_to_plot.groupby(["model", "unique_id"])
310
  .apply(aggregation, numeric_only=True)
311
  .reset_index()
312
  .pivot(index="model", columns="unique_id", values=f"{metric}.{aggregation}")
313
  )
 
 
 
 
 
 
 
314
 
315
  def custom_table(styler):
316
  styler.background_gradient(cmap="seismic", axis=None)
@@ -321,7 +356,7 @@ def performance_view(data: pd.DataFrame, models_to_plot: set[str]):
321
  return styler
322
 
323
  st.markdown(f"#### {aggregation.capitalize()} {metric} stats per building")
324
- styled_table = metrics_table.style.pipe(custom_table)
325
  st.dataframe(styled_table, use_container_width=True)
326
 
327
 
 
54
 
55
 
56
  def overview_view(data):
57
+ st.markdown(
58
+ """
59
  [EnFoBench](https://github.com/attila-balint-kul/energy-forecast-benchmark-toolkit)
60
  is a community driven benchmarking framework for energy forecasting models.
61
 
62
  This dashboard presents the results of the electricity demand forecasting usecase. All models were cross-validated
63
  on **365 days** of day ahead forecasting horizon *(10AM until midnight of the next day)*.
64
+ """
65
+ )
66
 
67
  st.divider()
68
  st.markdown("## Leaderboard")
 
71
 
72
  left, middle, right = st.columns(3)
73
  with left:
74
+ best_models_mae = (
75
+ leaderboard.sort_values("MAE.mean", ascending=False)
76
+ .head(10)
77
+ .sort_values("MAE.mean")
78
+ )
79
+ fig = px.bar(best_models_mae, x="MAE.mean", y=best_models_mae.index)
80
+ fig.update_layout(
81
+ title="Top 10 models by MAE", xaxis_title="", yaxis_title="Model"
82
+ )
83
  st.plotly_chart(fig, use_container_width=True)
84
 
85
  with middle:
86
+ best_models_mae = (
87
+ leaderboard.sort_values("RMSE.mean", ascending=False)
88
+ .head(10)
89
+ .sort_values("RMSE.mean")
90
+ )
91
+ fig = px.bar(best_models_mae, x="RMSE.mean", y=best_models_mae.index)
92
  fig.update_layout(title="Top 10 models by RMSE", xaxis_title="", yaxis_title="")
93
  st.plotly_chart(fig, use_container_width=True)
94
 
95
  with right:
96
+ best_models_mae = (
97
+ leaderboard.sort_values("rMAE.mean", ascending=False)
98
+ .head(10)
99
+ .sort_values("rMAE.mean")
100
+ )
101
+ fig = px.bar(best_models_mae, x="rMAE.mean", y=best_models_mae.index)
102
  fig.update_layout(title="Top 10 models by rMAE", xaxis_title="", yaxis_title="")
103
  st.plotly_chart(fig, use_container_width=True)
104
 
 
238
  "Aggregation", ["min", "mean", "median", "max", "std"], index=1
239
  )
240
  st.markdown(f"#### {aggregation.capitalize()} {metric} per building")
241
+
242
+ rank_df = (
243
+ data_to_plot.groupby(["model"])
244
+ .agg("median", numeric_only=True)
245
+ .sort_values(by=f"{metric}.{aggregation}")
246
+ .reset_index()
247
+ .rename_axis("rank")
248
+ .reset_index()[["rank", "model"]]
249
+ )
250
+
251
  fig = px.box(
252
+ data_to_plot.merge(rank_df, on="model").sort_values(by="rank"),
253
  x=f"{metric}.{aggregation}",
254
  y="model",
255
  color="model",
 
309
  key="table_aggregation",
310
  )
311
 
312
+ metrics_per_building_table = data_to_plot.groupby(["model"]).agg(
313
+ aggregation, numeric_only=True
314
+ )[
315
  [
316
  f"{metric}.min",
317
  f"{metric}.mean",
 
330
  return styler
331
 
332
  st.markdown(f"#### {aggregation.capitalize()} {metric} stats per model")
333
+ styled_table = metrics_per_building_table.style.pipe(custom_table)
334
  st.dataframe(styled_table, use_container_width=True)
335
 
336
+ metrics_per_building_table = (
337
  data_to_plot.groupby(["model", "unique_id"])
338
  .apply(aggregation, numeric_only=True)
339
  .reset_index()
340
  .pivot(index="model", columns="unique_id", values=f"{metric}.{aggregation}")
341
  )
342
+ metrics_per_building_table.insert(
343
+ 0, "median", metrics_per_building_table.median(axis=1)
344
+ )
345
+ metrics_per_building_table.insert(
346
+ 0, "mean", metrics_per_building_table.mean(axis=1)
347
+ )
348
+ metrics_per_building_table = metrics_per_building_table.sort_values(by="mean")
349
 
350
  def custom_table(styler):
351
  styler.background_gradient(cmap="seismic", axis=None)
 
356
  return styler
357
 
358
  st.markdown(f"#### {aggregation.capitalize()} {metric} stats per building")
359
+ styled_table = metrics_per_building_table.style.pipe(custom_table)
360
  st.dataframe(styled_table, use_container_width=True)
361
 
362