Shiyu Zhao commited on
Commit
28ab0f4
·
1 Parent(s): 0e60f5e

Update space

Browse files
Files changed (1) hide show
  1. app.py +10 -30
app.py CHANGED
@@ -465,7 +465,7 @@ def save_submission(submission_data, csv_file):
465
  def update_leaderboard_data(submission_data):
466
  """
467
  Update leaderboard data with new submission results
468
- Only updates the specific dataset submitted, preventing empty rows
469
  """
470
  global df_synthesized_full, df_synthesized_10, df_human_generated
471
 
@@ -477,32 +477,26 @@ def update_leaderboard_data(submission_data):
477
  }
478
 
479
  df_to_update = split_to_df[submission_data['Split']]
480
- dataset = submission_data['Dataset'].upper()
481
 
482
- # Prepare new row data with only the relevant dataset columns
483
  new_row = {
484
- 'Method': submission_data['Method Name']
 
 
 
 
485
  }
486
- # Only add metrics for the submitted dataset
487
- new_row.update({
488
- f'STARK-{dataset}_Hit@1': submission_data['results']['hit@1'],
489
- f'STARK-{dataset}_Hit@5': submission_data['results']['hit@5'],
490
- f'STARK-{dataset}_R@20': submission_data['results']['recall@20'],
491
- f'STARK-{dataset}_MRR': submission_data['results']['mrr']
492
- })
493
 
494
  # Check if method already exists
495
  method_mask = df_to_update['Method'] == submission_data['Method Name']
496
  if method_mask.any():
497
- # Update only the columns for the submitted dataset
498
  for col in new_row:
499
  df_to_update.loc[method_mask, col] = new_row[col]
500
  else:
501
- # For new methods, create a row with only the submitted dataset's values
502
  df_to_update.loc[len(df_to_update)] = new_row
503
 
504
-
505
-
506
  # Function to get emails from meta_data
507
  def get_emails_from_metadata(meta_data):
508
  """
@@ -792,24 +786,10 @@ def filter_by_model_type(df, selected_types):
792
  return df[df['Method'].isin(selected_models)]
793
 
794
  def format_dataframe(df, dataset):
795
- """
796
- Format DataFrame for display, removing rows with no data for the selected dataset
797
- """
798
- # Select relevant columns
799
  columns = ['Method'] + [col for col in df.columns if dataset in col]
800
  filtered_df = df[columns].copy()
801
-
802
- # Remove rows where all metric columns are empty/NaN for this dataset
803
- metric_columns = [col for col in filtered_df.columns if col != 'Method']
804
- filtered_df = filtered_df.dropna(subset=metric_columns, how='all')
805
-
806
- # Rename columns to remove dataset prefix
807
  filtered_df.columns = [col.split('_')[-1] if '_' in col else col for col in filtered_df.columns]
808
-
809
- # Sort by MRR
810
- if 'MRR' in filtered_df.columns:
811
- filtered_df = filtered_df.sort_values('MRR', ascending=False)
812
-
813
  return filtered_df
814
 
815
  def update_tables(selected_types):
 
465
  def update_leaderboard_data(submission_data):
466
  """
467
  Update leaderboard data with new submission results
468
+ Only uses model name in the displayed table
469
  """
470
  global df_synthesized_full, df_synthesized_10, df_human_generated
471
 
 
477
  }
478
 
479
  df_to_update = split_to_df[submission_data['Split']]
 
480
 
481
+ # Prepare new row data
482
  new_row = {
483
+ 'Method': submission_data['Method Name'], # Only use method name in table
484
+ f'STARK-{submission_data["Dataset"].upper()}_Hit@1': submission_data['results']['hit@1'],
485
+ f'STARK-{submission_data["Dataset"].upper()}_Hit@5': submission_data['results']['hit@5'],
486
+ f'STARK-{submission_data["Dataset"].upper()}_R@20': submission_data['results']['recall@20'],
487
+ f'STARK-{submission_data["Dataset"].upper()}_MRR': submission_data['results']['mrr']
488
  }
 
 
 
 
 
 
 
489
 
490
  # Check if method already exists
491
  method_mask = df_to_update['Method'] == submission_data['Method Name']
492
  if method_mask.any():
493
+ # Update existing row
494
  for col in new_row:
495
  df_to_update.loc[method_mask, col] = new_row[col]
496
  else:
497
+ # Add new row
498
  df_to_update.loc[len(df_to_update)] = new_row
499
 
 
 
500
  # Function to get emails from meta_data
501
  def get_emails_from_metadata(meta_data):
502
  """
 
786
  return df[df['Method'].isin(selected_models)]
787
 
788
  def format_dataframe(df, dataset):
 
 
 
 
789
  columns = ['Method'] + [col for col in df.columns if dataset in col]
790
  filtered_df = df[columns].copy()
 
 
 
 
 
 
791
  filtered_df.columns = [col.split('_')[-1] if '_' in col else col for col in filtered_df.columns]
792
+ filtered_df = filtered_df.sort_values('MRR', ascending=False)
 
 
 
 
793
  return filtered_df
794
 
795
  def update_tables(selected_types):