Spaces:
Sleeping
Sleeping
attilabalint
commited on
Commit
·
60bd8ab
1
Parent(s):
caad382
added computational resources
Browse files- app.py +17 -3
- components.py +55 -0
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
-
from components import buildings_view, models_view, performance_view
|
| 4 |
import utils
|
| 5 |
|
| 6 |
st.set_page_config(page_title="Electricity Demand Dashboard", layout="wide")
|
|
@@ -9,6 +9,7 @@ PAGES = [
|
|
| 9 |
"Buildings",
|
| 10 |
"Models",
|
| 11 |
"Performance",
|
|
|
|
| 12 |
]
|
| 13 |
|
| 14 |
|
|
@@ -27,7 +28,6 @@ models = sorted(data["model"].unique().tolist())
|
|
| 27 |
models_to_plot = set()
|
| 28 |
model_groups: dict[str, list[str]] = {}
|
| 29 |
|
| 30 |
-
|
| 31 |
for model in models:
|
| 32 |
group, model_name = model.split(".", maxsplit=1)
|
| 33 |
if group not in model_groups:
|
|
@@ -47,10 +47,22 @@ with st.sidebar:
|
|
| 47 |
view = st.selectbox("View", PAGES, index=0)
|
| 48 |
|
| 49 |
st.header("Models to include")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
for model_group, models in model_groups.items():
|
| 51 |
st.text(model_group)
|
| 52 |
for model_name in models:
|
| 53 |
-
to_plot = st.checkbox(model_name, value=True)
|
| 54 |
if to_plot:
|
| 55 |
models_to_plot.add(f"{model_group}.{model_name}")
|
| 56 |
|
|
@@ -64,5 +76,7 @@ elif view == "Models":
|
|
| 64 |
models_view(data)
|
| 65 |
elif view == "Performance":
|
| 66 |
performance_view(data, models_to_plot)
|
|
|
|
|
|
|
| 67 |
else:
|
| 68 |
st.write("Not implemented yet")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
+
from components import buildings_view, models_view, performance_view, computation_view
|
| 4 |
import utils
|
| 5 |
|
| 6 |
st.set_page_config(page_title="Electricity Demand Dashboard", layout="wide")
|
|
|
|
| 9 |
"Buildings",
|
| 10 |
"Models",
|
| 11 |
"Performance",
|
| 12 |
+
"Computational Resources",
|
| 13 |
]
|
| 14 |
|
| 15 |
|
|
|
|
| 28 |
models_to_plot = set()
|
| 29 |
model_groups: dict[str, list[str]] = {}
|
| 30 |
|
|
|
|
| 31 |
for model in models:
|
| 32 |
group, model_name = model.split(".", maxsplit=1)
|
| 33 |
if group not in model_groups:
|
|
|
|
| 47 |
view = st.selectbox("View", PAGES, index=0)
|
| 48 |
|
| 49 |
st.header("Models to include")
|
| 50 |
+
left, right = st.columns(2)
|
| 51 |
+
with left:
|
| 52 |
+
select_none = st.button("Select None", use_container_width=True)
|
| 53 |
+
if select_none:
|
| 54 |
+
for model in models:
|
| 55 |
+
st.session_state[model] = False
|
| 56 |
+
with right:
|
| 57 |
+
select_all = st.button("Select All", use_container_width=True)
|
| 58 |
+
if select_all:
|
| 59 |
+
for model in models:
|
| 60 |
+
st.session_state[model] = True
|
| 61 |
+
|
| 62 |
for model_group, models in model_groups.items():
|
| 63 |
st.text(model_group)
|
| 64 |
for model_name in models:
|
| 65 |
+
to_plot = st.checkbox(model_name, value=True, key=f"{model_group}.{model_name}")
|
| 66 |
if to_plot:
|
| 67 |
models_to_plot.add(f"{model_group}.{model_name}")
|
| 68 |
|
|
|
|
| 76 |
models_view(data)
|
| 77 |
elif view == "Performance":
|
| 78 |
performance_view(data, models_to_plot)
|
| 79 |
+
elif view == "Computational Resources":
|
| 80 |
+
computation_view(data, models_to_plot)
|
| 81 |
else:
|
| 82 |
st.write("Not implemented yet")
|
components.py
CHANGED
|
@@ -237,3 +237,58 @@ def performance_view(data: pd.DataFrame, models_to_plot: set[str]):
|
|
| 237 |
st.markdown(f"#### {aggregation.capitalize()} {metric} stats per building")
|
| 238 |
styled_table = metrics_table.style.pipe(custom_table)
|
| 239 |
st.dataframe(styled_table, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
st.markdown(f"#### {aggregation.capitalize()} {metric} stats per building")
|
| 238 |
styled_table = metrics_table.style.pipe(custom_table)
|
| 239 |
st.dataframe(styled_table, use_container_width=True)
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
def computation_view(data, models_to_plot: set[str]):
|
| 243 |
+
data_to_plot = data[data["model"].isin(models_to_plot)].sort_values(
|
| 244 |
+
by="model", ascending=True
|
| 245 |
+
)
|
| 246 |
+
|
| 247 |
+
st.markdown("#### Computational Resources")
|
| 248 |
+
fig = px.parallel_coordinates(
|
| 249 |
+
data_to_plot.groupby("model").mean(numeric_only=True).reset_index(),
|
| 250 |
+
dimensions=[
|
| 251 |
+
"model",
|
| 252 |
+
"resource_usage.CPU",
|
| 253 |
+
"resource_usage.memory",
|
| 254 |
+
"MAE.mean",
|
| 255 |
+
"RMSE.mean",
|
| 256 |
+
"MBE.mean",
|
| 257 |
+
"rMAE.mean",
|
| 258 |
+
],
|
| 259 |
+
color="rMAE.mean",
|
| 260 |
+
color_continuous_scale=px.colors.diverging.Portland,
|
| 261 |
+
)
|
| 262 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 263 |
+
|
| 264 |
+
st.divider()
|
| 265 |
+
|
| 266 |
+
left, center, right = st.columns(3, gap="small")
|
| 267 |
+
with left:
|
| 268 |
+
metric = st.selectbox("Metric", ["MAE", "RMSE", "MBE", "rMAE"], index=0)
|
| 269 |
+
with center:
|
| 270 |
+
aggregation_per_building = st.selectbox(
|
| 271 |
+
"Aggregation per building", ["min", "mean", "median", "max", "std"], index=1
|
| 272 |
+
)
|
| 273 |
+
with right:
|
| 274 |
+
aggregation_per_model = st.selectbox(
|
| 275 |
+
"Aggregation per model", ["min", "mean", "median", "max", "std"], index=1
|
| 276 |
+
)
|
| 277 |
+
|
| 278 |
+
st.markdown(
|
| 279 |
+
f"#### {aggregation_per_model.capitalize()} {aggregation_per_building.capitalize()} {metric} vs CPU usage"
|
| 280 |
+
)
|
| 281 |
+
aggregated_data = (
|
| 282 |
+
data_to_plot.groupby("model")
|
| 283 |
+
.agg(aggregation_per_building, numeric_only=True)
|
| 284 |
+
.reset_index()
|
| 285 |
+
)
|
| 286 |
+
fig = px.scatter(
|
| 287 |
+
aggregated_data,
|
| 288 |
+
x="resource_usage.CPU",
|
| 289 |
+
y=f"{metric}.{aggregation_per_model}",
|
| 290 |
+
color="model",
|
| 291 |
+
log_x=True,
|
| 292 |
+
)
|
| 293 |
+
fig.update_layout(height=600)
|
| 294 |
+
st.plotly_chart(fig, use_container_width=True)
|