philippds commited on
Commit
e5ce742
·
verified ·
1 Parent(s): eedc54f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -131,16 +131,12 @@ def update_leaderboard_dataset_parallel(hivex_env, path):
131
  row = {}
132
  row["User"] = user_id
133
  row["Model"] = model_id
134
- # accuracy = parse_metrics_accuracy(meta)
135
- # mean_reward, std_reward = parse_rewards(accuracy)
136
- # mean_reward = mean_reward if not pd.isna(mean_reward) else 0
137
- # std_reward = std_reward if not pd.isna(std_reward) else 0
138
- # row["Results"] = mean_reward - std_reward
139
- # row["Mean Reward"] = mean_reward
140
- # row["Std Reward"] = std_reward
141
- results = meta["model-index"][0]["results"][0]["metrics"]
142
-
143
- for result in results:
144
  row[result["name"]] = float(result["value"].split("+/-")[0].strip())
145
 
146
  return row
@@ -172,21 +168,25 @@ def run_update_dataset():
172
  )
173
 
174
 
175
- def get_data(rl_env, path) -> pd.DataFrame:
176
  """
177
- Get data from rl_env
178
- :return: data as a pandas DataFrame
179
  """
180
  csv_path = path + "/" + rl_env + ".csv"
181
  data = pd.read_csv(csv_path)
182
 
183
- for index, row in data.iterrows():
 
 
 
 
184
  user_id = row["User"]
185
- data.loc[index, "User"] = make_clickable_user(user_id)
186
  model_id = row["Model"]
187
- data.loc[index, "Model"] = make_clickable_model(model_id)
188
 
189
- return data
190
 
191
 
192
  def get_data_no_html(rl_env, path) -> pd.DataFrame:
@@ -221,7 +221,7 @@ with block:
221
  with gr.TabItem(f"Task {j}"):
222
  with gr.Row():
223
  # gr_dataframe = gr.components.Dataframe(value=get_data(hivex_env["hivex_env"], path_), headers=["User", "Model", "Cumulative Reward"], datatype=["markdown", "markdown", "number"], row_count=(100, 'fixed'))
224
- gr_dataframe = gr.components.Dataframe(value=get_data(hivex_env["hivex_env"], path_), headers=["Ranking", "User", "Model"], datatype=["number", "markdown", "markdown"], row_count=(100, 'fixed'))
225
 
226
 
227
  scheduler = BackgroundScheduler()
 
131
  row = {}
132
  row["User"] = user_id
133
  row["Model"] = model_id
134
+ results = meta["model-index"][0]["results"][0]
135
+ row["Task"] = results["task"]["task-id"]
136
+
137
+ results_metrics = results["metrics"]
138
+
139
+ for result in results_metrics:
 
 
 
 
140
  row[result["name"]] = float(result["value"].split("+/-")[0].strip())
141
 
142
  return row
 
168
  )
169
 
170
 
171
+ def get_data(rl_env, task, path) -> pd.DataFrame:
172
  """
173
+ Get data from rl_env and filter by the given task.
174
+ :return: filtered data as a pandas DataFrame
175
  """
176
  csv_path = path + "/" + rl_env + ".csv"
177
  data = pd.read_csv(csv_path)
178
 
179
+ # Filter the data to only include rows where the "Task" column matches the given task
180
+ filtered_data = data[data["Task"] == task]
181
+
182
+ # Convert User and Model columns to clickable links
183
+ for index, row in filtered_data.iterrows():
184
  user_id = row["User"]
185
+ filtered_data.loc[index, "User"] = make_clickable_user(user_id)
186
  model_id = row["Model"]
187
+ filtered_data.loc[index, "Model"] = make_clickable_model(model_id)
188
 
189
+ return filtered_data
190
 
191
 
192
  def get_data_no_html(rl_env, path) -> pd.DataFrame:
 
221
  with gr.TabItem(f"Task {j}"):
222
  with gr.Row():
223
  # gr_dataframe = gr.components.Dataframe(value=get_data(hivex_env["hivex_env"], path_), headers=["User", "Model", "Cumulative Reward"], datatype=["markdown", "markdown", "number"], row_count=(100, 'fixed'))
224
+ gr_dataframe = gr.components.Dataframe(value=get_data(hivex_env["hivex_env"], j,path_), headers=["Ranking", "User", "Model"], datatype=["number", "markdown", "markdown"], row_count=(100, 'fixed'))
225
 
226
 
227
  scheduler = BackgroundScheduler()