djstrong commited on
Commit
bddad3e
1 Parent(s): 918265b

set precision

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -4,6 +4,7 @@ import numpy as np
4
  import pandas as pd
5
  from apscheduler.schedulers.background import BackgroundScheduler
6
  from huggingface_hub import snapshot_download
 
7
 
8
  from src.about import (
9
  CITATION_BUTTON_LABEL,
@@ -11,7 +12,7 @@ from src.about import (
11
  EVALUATION_QUEUE_TEXT,
12
  INTRODUCTION_TEXT,
13
  LLM_BENCHMARKS_TEXT,
14
- TITLE,
15
  )
16
  from src.display.css_html_js import custom_css
17
  from src.display.utils import (
@@ -66,6 +67,15 @@ leaderboard_df = original_df.copy()
66
  pending_eval_queue_df,
67
  ) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
68
 
 
 
 
 
 
 
 
 
 
69
 
70
  # Searching and filtering
71
  def update_table(
@@ -87,10 +97,7 @@ def update_table(
87
 
88
  df = df.replace({'': np.nan})
89
 
90
- leaderboard_df_styled = df.style.background_gradient(cmap="viridis")
91
- # leaderboard_df_styled = leaderboard_df_styled.format("{:.2f}")
92
- return leaderboard_df_styled
93
-
94
 
95
  def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
96
  return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
@@ -226,8 +233,9 @@ with demo:
226
  + shown_columns.value
227
  + [AutoEvalColumn.dummy.name]
228
  ]
229
- leaderboard_df_styled = leaderboard_table_value.style.background_gradient(cmap="viridis")
230
- # leaderboard_df_styled = leaderboard_df_styled.format("{:.2f}")
 
231
  leaderboard_df_styled.precision = 2
232
 
233
  leaderboard_table = gr.components.Dataframe(
 
4
  import pandas as pd
5
  from apscheduler.schedulers.background import BackgroundScheduler
6
  from huggingface_hub import snapshot_download
7
+ from pandas.io.formats.style import Styler
8
 
9
  from src.about import (
10
  CITATION_BUTTON_LABEL,
 
12
  EVALUATION_QUEUE_TEXT,
13
  INTRODUCTION_TEXT,
14
  LLM_BENCHMARKS_TEXT,
15
+ TITLE, Tasks,
16
  )
17
  from src.display.css_html_js import custom_css
18
  from src.display.utils import (
 
67
  pending_eval_queue_df,
68
  ) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
69
 
70
+ def style_df(df: pd.DataFrame) -> Styler:
71
+ leaderboard_df_styled = df.style.background_gradient(cmap="viridis")
72
+ rounding = {'#Params (B)': "{:.1f}"}
73
+ for task in Tasks:
74
+ rounding[task.value.col_name] = "{:.2f}"
75
+ for column_name in ["Average ⬆️", "Avg g", "Avg mc"]:
76
+ rounding[column_name] = "{:.2f}"
77
+ leaderboard_df_styled = leaderboard_df_styled.format(rounding)
78
+ return leaderboard_df_styled
79
 
80
  # Searching and filtering
81
  def update_table(
 
97
 
98
  df = df.replace({'': np.nan})
99
 
100
+ return style_df(df)
 
 
 
101
 
102
  def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
103
  return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False))]
 
233
  + shown_columns.value
234
  + [AutoEvalColumn.dummy.name]
235
  ]
236
+ leaderboard_df_styled=style_df(leaderboard_table_value)
237
+
238
+
239
  leaderboard_df_styled.precision = 2
240
 
241
  leaderboard_table = gr.components.Dataframe(