Spaces:
Sleeping
Sleeping
Added sorting to performance tab
Browse files- components.py +20 -3
components.py
CHANGED
|
@@ -222,8 +222,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",
|
|
@@ -305,12 +315,19 @@ def performance_view(data: pd.DataFrame, models_to_plot: set[str]):
|
|
| 305 |
styled_table = metrics_table.style.pipe(custom_table)
|
| 306 |
st.dataframe(styled_table, use_container_width=True)
|
| 307 |
|
| 308 |
-
|
| 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 +338,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 =
|
| 325 |
st.dataframe(styled_table, use_container_width=True)
|
| 326 |
|
| 327 |
|
|
|
|
| 222 |
"Aggregation", ["min", "mean", "median", "max", "std"], index=1
|
| 223 |
)
|
| 224 |
st.markdown(f"#### {aggregation.capitalize()} {metric} per building")
|
| 225 |
+
|
| 226 |
+
rank_df = (
|
| 227 |
+
data_to_plot.groupby(["model"])
|
| 228 |
+
.agg("median", numeric_only=True)
|
| 229 |
+
.sort_values(by=f"{metric}.{aggregation}")
|
| 230 |
+
.reset_index()
|
| 231 |
+
.rename_axis("rank")
|
| 232 |
+
.reset_index()[["rank", "model"]]
|
| 233 |
+
)
|
| 234 |
+
|
| 235 |
fig = px.box(
|
| 236 |
+
data_to_plot.merge(rank_df, on="model").sort_values(by="rank"),
|
| 237 |
x=f"{metric}.{aggregation}",
|
| 238 |
y="model",
|
| 239 |
color="model",
|
|
|
|
| 315 |
styled_table = metrics_table.style.pipe(custom_table)
|
| 316 |
st.dataframe(styled_table, use_container_width=True)
|
| 317 |
|
| 318 |
+
metrics_per_building_table = (
|
| 319 |
data_to_plot.groupby(["model", "unique_id"])
|
| 320 |
.apply(aggregation, numeric_only=True)
|
| 321 |
.reset_index()
|
| 322 |
.pivot(index="model", columns="unique_id", values=f"{metric}.{aggregation}")
|
| 323 |
)
|
| 324 |
+
metrics_per_building_table.insert(
|
| 325 |
+
0, "median", metrics_per_building_table.median(axis=1)
|
| 326 |
+
)
|
| 327 |
+
metrics_per_building_table.insert(
|
| 328 |
+
0, "mean", metrics_per_building_table.mean(axis=1)
|
| 329 |
+
)
|
| 330 |
+
metrics_per_building_table = metrics_per_building_table.sort_values(by="mean")
|
| 331 |
|
| 332 |
def custom_table(styler):
|
| 333 |
styler.background_gradient(cmap="seismic", axis=None)
|
|
|
|
| 338 |
return styler
|
| 339 |
|
| 340 |
st.markdown(f"#### {aggregation.capitalize()} {metric} stats per building")
|
| 341 |
+
styled_table = metrics_per_building_table.style.pipe(custom_table)
|
| 342 |
st.dataframe(styled_table, use_container_width=True)
|
| 343 |
|
| 344 |
|