Spaces:
Running
Running
Shiyu Zhao
commited on
Commit
·
5915a5d
1
Parent(s):
d6115d0
Update space
Browse files
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
|
| 469 |
"""
|
| 470 |
global df_synthesized_full, df_synthesized_10, df_human_generated
|
| 471 |
|
|
@@ -477,26 +477,32 @@ def update_leaderboard_data(submission_data):
|
|
| 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']
|
| 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
|
| 494 |
for col in new_row:
|
| 495 |
df_to_update.loc[method_mask, col] = new_row[col]
|
| 496 |
else:
|
| 497 |
-
#
|
| 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 |
"""
|
|
@@ -689,7 +695,7 @@ def process_submission(
|
|
| 689 |
submission_data = {
|
| 690 |
**meta_data,
|
| 691 |
"results": processed_results,
|
| 692 |
-
"status": "
|
| 693 |
"submission_date": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
| 694 |
"csv_path": csv_path_in_repo
|
| 695 |
}
|
|
@@ -711,7 +717,7 @@ def process_submission(
|
|
| 711 |
# 3. Create or update latest.json
|
| 712 |
latest_info = {
|
| 713 |
"latest_submission": timestamp,
|
| 714 |
-
"status": "
|
| 715 |
"method_name": method_name,
|
| 716 |
"team_name": team_name
|
| 717 |
}
|
|
@@ -786,10 +792,24 @@ def filter_by_model_type(df, selected_types):
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 793 |
return filtered_df
|
| 794 |
|
| 795 |
def update_tables(selected_types):
|
|
|
|
| 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 |
}
|
| 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 |
"""
|
|
|
|
| 695 |
submission_data = {
|
| 696 |
**meta_data,
|
| 697 |
"results": processed_results,
|
| 698 |
+
"status": "pending_review", # or "approved"
|
| 699 |
"submission_date": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
| 700 |
"csv_path": csv_path_in_repo
|
| 701 |
}
|
|
|
|
| 717 |
# 3. Create or update latest.json
|
| 718 |
latest_info = {
|
| 719 |
"latest_submission": timestamp,
|
| 720 |
+
"status": "pending_review", # or "approved"
|
| 721 |
"method_name": method_name,
|
| 722 |
"team_name": team_name
|
| 723 |
}
|
|
|
|
| 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):
|
src/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
submissions/debug_submission_none/latest.json
DELETED
|
@@ -1,6 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"latest_submission": "20241024_125801",
|
| 3 |
-
"status": "approved",
|
| 4 |
-
"method_name": "debug-submission",
|
| 5 |
-
"team_name": "none"
|
| 6 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
submissions/debug_submission_none/metadata_20241024_125801.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"Method Name": "debug-submission",
|
| 3 |
-
"Team Name": "none",
|
| 4 |
-
"Dataset": "mag",
|
| 5 |
-
"Split": "human_generated_eval",
|
| 6 |
-
"Contact Email(s)": "none",
|
| 7 |
-
"Code Repository": "none",
|
| 8 |
-
"Model Description": "none",
|
| 9 |
-
"Hardware": "none",
|
| 10 |
-
"(Optional) Paper link": "none",
|
| 11 |
-
"Model Type": "Others",
|
| 12 |
-
"results": {
|
| 13 |
-
"hit@1": 28.57,
|
| 14 |
-
"hit@5": 41.67,
|
| 15 |
-
"recall@20": 35.95,
|
| 16 |
-
"mrr": 35.94
|
| 17 |
-
},
|
| 18 |
-
"status": "approved",
|
| 19 |
-
"submission_date": "2024-10-24 12:58:41",
|
| 20 |
-
"csv_path": "submissions/debug_submission_none/predictions_20241024_125801.csv"
|
| 21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
submissions/debug_submission_none/predictions_20241024_125801.csv
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|