ziyuzhou02 commited on
Commit
890f9bf
·
verified ·
1 Parent(s): 7784e8f

Clarify overall tables and tracked rank history

Browse files
Files changed (1) hide show
  1. src/utils.py +9 -6
src/utils.py CHANGED
@@ -804,24 +804,27 @@ BASELINE_RANK_HISTORY_COLUMNS = [
804
  ]
805
 
806
  _RANK_COLS = [c for c in BASELINE_RANK_HISTORY_COLUMNS if c.endswith("_Rank")]
807
- _DAILY_DISPLAY_COLS = ["date"] + _RANK_COLS
808
- _WEEKLY_DISPLAY_COLS = ["week"] + _RANK_COLS
809
 
810
 
811
  def _read_rank_history(path: Path, date_col: str) -> pd.DataFrame:
812
  """Read a rank history CSV, coerce rank columns to float, sort by date_col."""
813
  if not path.exists():
814
- return pd.DataFrame(columns=[date_col] + _RANK_COLS)
815
  try:
816
  df = pd.read_csv(path)
817
  except Exception:
818
- return pd.DataFrame(columns=[date_col] + _RANK_COLS)
819
  for col in _RANK_COLS:
820
  if col in df.columns:
821
  df[col] = pd.to_numeric(df[col], errors="coerce").map(format_rank_number)
822
  if date_col in df.columns:
823
  df = df.sort_values(date_col)
824
- present = [c for c in [date_col] + _RANK_COLS if c in df.columns]
 
 
 
825
  return df[present].reset_index(drop=True)
826
 
827
 
@@ -1014,7 +1017,7 @@ def make_rank_trend_plot(history_df: pd.DataFrame, metrics: list[str] | None = N
1014
  ))
1015
 
1016
  fig.update_layout(
1017
- title=dict(text="Baseline rank trend over time (lower is better)", font=dict(size=14)),
1018
  xaxis_title=date_col.capitalize(),
1019
  yaxis_title="Average rank",
1020
  legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
 
804
  ]
805
 
806
  _RANK_COLS = [c for c in BASELINE_RANK_HISTORY_COLUMNS if c.endswith("_Rank")]
807
+ _DAILY_DISPLAY_COLS = ["date", "model"] + _RANK_COLS
808
+ _WEEKLY_DISPLAY_COLS = ["week", "model"] + _RANK_COLS
809
 
810
 
811
  def _read_rank_history(path: Path, date_col: str) -> pd.DataFrame:
812
  """Read a rank history CSV, coerce rank columns to float, sort by date_col."""
813
  if not path.exists():
814
+ return pd.DataFrame(columns=[date_col, "model"] + _RANK_COLS)
815
  try:
816
  df = pd.read_csv(path)
817
  except Exception:
818
+ return pd.DataFrame(columns=[date_col, "model"] + _RANK_COLS)
819
  for col in _RANK_COLS:
820
  if col in df.columns:
821
  df[col] = pd.to_numeric(df[col], errors="coerce").map(format_rank_number)
822
  if date_col in df.columns:
823
  df = df.sort_values(date_col)
824
+ sort_cols = [c for c in (date_col, "model") if c in df.columns]
825
+ if sort_cols:
826
+ df = df.sort_values(sort_cols)
827
+ present = [c for c in [date_col, "model"] + _RANK_COLS if c in df.columns]
828
  return df[present].reset_index(drop=True)
829
 
830
 
 
1017
  ))
1018
 
1019
  fig.update_layout(
1020
+ title=dict(text="Tracked model rank trend over time (lower is better)", font=dict(size=14)),
1021
  xaxis_title=date_col.capitalize(),
1022
  yaxis_title="Average rank",
1023
  legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),