Spaces:
Running
Running
Deploy Space: update src
Browse files- src/utils.py +21 -12
src/utils.py
CHANGED
|
@@ -463,8 +463,17 @@ def make_forecast_plot(snapshot: dict | None) -> object | None:
|
|
| 463 |
n_ctx = len(ctx)
|
| 464 |
n_fut = len(actuals)
|
| 465 |
|
| 466 |
-
|
| 467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
|
| 469 |
fig = go.Figure()
|
| 470 |
|
|
@@ -513,24 +522,24 @@ def make_forecast_plot(snapshot: dict | None) -> object | None:
|
|
| 513 |
text=f"{dataset_label} — {model_label} ({evaluated_at})",
|
| 514 |
font=dict(size=14),
|
| 515 |
),
|
| 516 |
-
xaxis_title=
|
| 517 |
yaxis_title="Value",
|
| 518 |
legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
|
| 519 |
margin=dict(l=40, r=20, t=60, b=40),
|
| 520 |
height=350,
|
| 521 |
paper_bgcolor="rgba(0,0,0,0)",
|
| 522 |
plot_bgcolor="rgba(0,0,0,0)",
|
| 523 |
-
font=dict(color="
|
| 524 |
-
xaxis=dict(gridcolor="rgba(
|
| 525 |
-
yaxis=dict(gridcolor="rgba(
|
| 526 |
)
|
| 527 |
# Vertical line separating context from forecast
|
| 528 |
fig.add_vline(
|
| 529 |
-
x=
|
| 530 |
line_dash="dot",
|
| 531 |
-
line_color="rgba(
|
| 532 |
annotation_text="forecast start",
|
| 533 |
-
annotation_font_color="
|
| 534 |
)
|
| 535 |
return fig
|
| 536 |
|
|
@@ -578,8 +587,8 @@ def make_rank_trend_plot(history_df: pd.DataFrame, metrics: list[str] | None = N
|
|
| 578 |
height=320,
|
| 579 |
paper_bgcolor="rgba(0,0,0,0)",
|
| 580 |
plot_bgcolor="rgba(0,0,0,0)",
|
| 581 |
-
font=dict(color="
|
| 582 |
-
xaxis=dict(gridcolor="rgba(
|
| 583 |
-
yaxis=dict(gridcolor="rgba(
|
| 584 |
)
|
| 585 |
return fig
|
|
|
|
| 463 |
n_ctx = len(ctx)
|
| 464 |
n_fut = len(actuals)
|
| 465 |
|
| 466 |
+
timestamps = snapshot.get("timestamps", [])
|
| 467 |
+
if timestamps and len(timestamps) == n_ctx + n_fut:
|
| 468 |
+
ctx_x = timestamps[:n_ctx]
|
| 469 |
+
fut_x = timestamps[n_ctx:]
|
| 470 |
+
x_title = "Time"
|
| 471 |
+
vline_x = fut_x[0]
|
| 472 |
+
else:
|
| 473 |
+
ctx_x = list(range(n_ctx))
|
| 474 |
+
fut_x = list(range(n_ctx, n_ctx + n_fut))
|
| 475 |
+
x_title = "Time step"
|
| 476 |
+
vline_x = n_ctx - 0.5
|
| 477 |
|
| 478 |
fig = go.Figure()
|
| 479 |
|
|
|
|
| 522 |
text=f"{dataset_label} — {model_label} ({evaluated_at})",
|
| 523 |
font=dict(size=14),
|
| 524 |
),
|
| 525 |
+
xaxis_title=x_title,
|
| 526 |
yaxis_title="Value",
|
| 527 |
legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
|
| 528 |
margin=dict(l=40, r=20, t=60, b=40),
|
| 529 |
height=350,
|
| 530 |
paper_bgcolor="rgba(0,0,0,0)",
|
| 531 |
plot_bgcolor="rgba(0,0,0,0)",
|
| 532 |
+
font=dict(color="black"),
|
| 533 |
+
xaxis=dict(gridcolor="rgba(0,0,0,0.08)"),
|
| 534 |
+
yaxis=dict(gridcolor="rgba(0,0,0,0.08)"),
|
| 535 |
)
|
| 536 |
# Vertical line separating context from forecast
|
| 537 |
fig.add_vline(
|
| 538 |
+
x=vline_x,
|
| 539 |
line_dash="dot",
|
| 540 |
+
line_color="rgba(0,0,0,0.3)",
|
| 541 |
annotation_text="forecast start",
|
| 542 |
+
annotation_font_color="black",
|
| 543 |
)
|
| 544 |
return fig
|
| 545 |
|
|
|
|
| 587 |
height=320,
|
| 588 |
paper_bgcolor="rgba(0,0,0,0)",
|
| 589 |
plot_bgcolor="rgba(0,0,0,0)",
|
| 590 |
+
font=dict(color="black"),
|
| 591 |
+
xaxis=dict(gridcolor="rgba(0,0,0,0.08)"),
|
| 592 |
+
yaxis=dict(gridcolor="rgba(0,0,0,0.08)"),
|
| 593 |
)
|
| 594 |
return fig
|