Maria Castellanos commited on
Commit
baeca97
·
1 Parent(s): 6fc2c2d

Fix mean of endpoints

Browse files
Files changed (2) hide show
  1. app.py +29 -9
  2. evaluate.py +9 -1
app.py CHANGED
@@ -13,21 +13,22 @@ def make_user_clickable(name):
13
  link =f'https://huggingface.co/{name}'
14
  return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{name}</a>'
15
  def make_tag_clickable(tag):
16
- return f'<a target="_blank" href="{tag}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">Report</a>'
17
 
18
  def get_leaderboard(endpoint):
19
  dset = load_dataset(results_repo, split='train', download_mode="force_redownload")
20
  full_df = dset.to_pandas()
21
  to_show = full_df.copy(deep=True)
22
  to_show = to_show[to_show['endpoint'] == endpoint]
 
23
  to_show['user'] = to_show['user'].apply(lambda x: make_user_clickable(x)).astype(str)
 
24
  # Get the most recent submission
25
  to_show["submission_time"] = pd.to_datetime(to_show["submission_time"])
26
  latest_per_user = to_show.loc[to_show.groupby("user")["submission_time"].idxmax()].reset_index(drop=True)
27
  latest_per_user.rename(columns={"submission_time": "submission time"}, inplace=True)
28
  # The columns to display publicly
29
- df = latest_per_user[["user", "MAE", "R2", "Spearman R", "Kendall's Tau", "submission time"]]
30
- # TODO: Also display the column with report link and make it clickable with make_tag_clickable
31
 
32
  return df
33
 
@@ -102,29 +103,48 @@ def gradio_interface():
102
  """
103
 
104
  # --- Gradio Interface ---
 
 
 
 
 
 
 
 
105
  with gr.Tabs(elem_classes="tab-buttons"):
106
  lboard_dict = {}
107
 
108
  with gr.TabItem("📝About"):
109
  gr.Markdown(welcome_md)
110
 
111
- with gr.TabItem("🚀Leaderboard"):
112
  gr.Markdown("View the leaderboard for each ADMET endpoint by selecting the appropiate tab.")
113
  # Make separate leaderboards in separate tabs
 
 
 
 
 
 
 
 
 
 
114
  for endpoint in ENDPOINTS:
115
  with gr.TabItem(endpoint):
116
  lboard_dict[endpoint] = Leaderboard(
117
  value=get_leaderboard(endpoint),
118
- datatype=['markdown', 'number', 'number', 'number', 'number'],
119
- select_columns=["user", "MAE", "R2", "Spearman R", "Kendall's Tau", "submission time"],
120
  search_columns=["user"],
 
121
  )
122
- # TODO: Make aggregated leaderboard and display on first tab
123
 
124
  with gr.TabItem("Submit Predictions"):
125
  gr.Markdown(
126
  """
127
- # ADME Endpoints Submission
128
  Upload your prediction files here as a csv file.
129
  """
130
  )
@@ -195,7 +215,7 @@ def gradio_interface():
195
  """
196
  )
197
  with gr.Column():
198
- predictions_file = gr.File(label="Single file with ADME predictions (.csv)",
199
  file_types=[".csv"],
200
  file_count="single",)
201
 
 
13
  link =f'https://huggingface.co/{name}'
14
  return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{name}</a>'
15
  def make_tag_clickable(tag):
16
+ return f'<a target="_blank" href="{tag}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">link</a>'
17
 
18
  def get_leaderboard(endpoint):
19
  dset = load_dataset(results_repo, split='train', download_mode="force_redownload")
20
  full_df = dset.to_pandas()
21
  to_show = full_df.copy(deep=True)
22
  to_show = to_show[to_show['endpoint'] == endpoint]
23
+ to_show = to_show[to_show['user'] != 'test']
24
  to_show['user'] = to_show['user'].apply(lambda x: make_user_clickable(x)).astype(str)
25
+ to_show['model details'] = to_show['model_report'].apply(lambda x: make_tag_clickable(x)).astype(str)
26
  # Get the most recent submission
27
  to_show["submission_time"] = pd.to_datetime(to_show["submission_time"])
28
  latest_per_user = to_show.loc[to_show.groupby("user")["submission_time"].idxmax()].reset_index(drop=True)
29
  latest_per_user.rename(columns={"submission_time": "submission time"}, inplace=True)
30
  # The columns to display publicly
31
+ df = latest_per_user[["user", "MAE", "R2", "Spearman R", "Kendall's Tau", "submission time", "model details"]]
 
32
 
33
  return df
34
 
 
103
  """
104
 
105
  # --- Gradio Interface ---
106
+ gr.HTML("""
107
+ <style>
108
+ /* bold only the "Overall" tab label */
109
+ #lb_subtabs [role="tab"][aria-controls="all_tab"] {
110
+ font-weight: 700 !important;
111
+ }
112
+ </style>
113
+ """)
114
  with gr.Tabs(elem_classes="tab-buttons"):
115
  lboard_dict = {}
116
 
117
  with gr.TabItem("📝About"):
118
  gr.Markdown(welcome_md)
119
 
120
+ with gr.TabItem("🚀Leaderboard", elem_id="lb_subtabs"):
121
  gr.Markdown("View the leaderboard for each ADMET endpoint by selecting the appropiate tab.")
122
  # Make separate leaderboards in separate tabs
123
+ # Aggregated leaderboard
124
+ with gr.TabItem('OVERALL', elem_id="all_tab"):
125
+ lboard_dict['Average'] = Leaderboard(
126
+ value=get_leaderboard('Average'),
127
+ datatype=['markdown', 'number', 'number', 'number', 'number', 'str', 'markdown'],
128
+ select_columns=["user", "MAE", "R2", "Spearman R", "Kendall's Tau", "submission time", "model details"],
129
+ search_columns=["user"],
130
+ render=True
131
+ )
132
+ # per-endpoint leaderboard
133
  for endpoint in ENDPOINTS:
134
  with gr.TabItem(endpoint):
135
  lboard_dict[endpoint] = Leaderboard(
136
  value=get_leaderboard(endpoint),
137
+ datatype=['markdown', 'number', 'number', 'number', 'number', 'str', 'markdown'],
138
+ select_columns=["user", "MAE", "R2", "Spearman R", "Kendall's Tau", "submission time", "model details"],
139
  search_columns=["user"],
140
+ render=True
141
  )
142
+
143
 
144
  with gr.TabItem("Submit Predictions"):
145
  gr.Markdown(
146
  """
147
+ # ADMET Endpoints Submission
148
  Upload your prediction files here as a csv file.
149
  """
150
  )
 
215
  """
216
  )
217
  with gr.Column():
218
+ predictions_file = gr.File(label="Single file with ADMET predictions (.csv)",
219
  file_types=[".csv"],
220
  file_count="single",)
221
 
evaluate.py CHANGED
@@ -162,12 +162,14 @@ def evaluate_data(filename: str) -> None:
162
  meta = SubmissionMetadata(**_meta)
163
  username = meta.participant.hf_username
164
  timestamp = meta.submission_time_utc
 
165
  except Exception as e:
166
  raise gr.Error(f"Failed to load metadata file: {e}. No results written to results dataset.")
167
 
168
  # Write results to results dataset
169
  results_df['user'] = username
170
  results_df['submission_time'] = timestamp
 
171
  safe_user = _unsafify_username(username)
172
  destination_path = f"results/{safe_user}_{timestamp}_results.csv"
173
  tmp_name = None
@@ -212,4 +214,10 @@ def calculate_metrics(
212
  df_results.loc[i, 'Spearman R'] = spearman
213
  df_results.loc[i, "Kendall's Tau"] = ktau
214
 
215
- return df_results
 
 
 
 
 
 
 
162
  meta = SubmissionMetadata(**_meta)
163
  username = meta.participant.hf_username
164
  timestamp = meta.submission_time_utc
165
+ report = meta.participant.model_tag
166
  except Exception as e:
167
  raise gr.Error(f"Failed to load metadata file: {e}. No results written to results dataset.")
168
 
169
  # Write results to results dataset
170
  results_df['user'] = username
171
  results_df['submission_time'] = timestamp
172
+ results_df['model_report'] = report
173
  safe_user = _unsafify_username(username)
174
  destination_path = f"results/{safe_user}_{timestamp}_results.csv"
175
  tmp_name = None
 
214
  df_results.loc[i, 'Spearman R'] = spearman
215
  df_results.loc[i, "Kendall's Tau"] = ktau
216
 
217
+ num_cols = ["MAE", "R2", "Spearman R", "Kendall's Tau"]
218
+ df_results[num_cols] = df_results[num_cols].apply(pd.to_numeric, errors="coerce")
219
+ means = df_results[num_cols].mean()
220
+ avg_row = {"endpoint": "Average", **means.to_dict()}
221
+ df_with_average = pd.concat([df_results, pd.DataFrame([avg_row])], ignore_index=True)
222
+
223
+ return df_with_average