ziyuzhou02 commited on
Commit
d7fdd4c
·
verified ·
1 Parent(s): 77b7510

Deploy Space: update src

Browse files
Files changed (1) hide show
  1. 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
- ctx_x = list(range(n_ctx))
467
- fut_x = list(range(n_ctx, n_ctx + n_fut))
 
 
 
 
 
 
 
 
 
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="Time step",
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="#e2e8f0"),
524
- xaxis=dict(gridcolor="rgba(255,255,255,0.08)"),
525
- yaxis=dict(gridcolor="rgba(255,255,255,0.08)"),
526
  )
527
  # Vertical line separating context from forecast
528
  fig.add_vline(
529
- x=n_ctx - 0.5,
530
  line_dash="dot",
531
- line_color="rgba(255,255,255,0.3)",
532
  annotation_text="forecast start",
533
- annotation_font_color="#94a3b8",
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="#e2e8f0"),
582
- xaxis=dict(gridcolor="rgba(255,255,255,0.08)"),
583
- yaxis=dict(gridcolor="rgba(255,255,255,0.08)"),
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