apsys commited on
Commit
7ccabe3
·
1 Parent(s): e471199

style theme

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -266,9 +266,9 @@ def init_leaderboard(dataframe, visible_columns=None):
266
  visible_columns = ['model_name'] + visible_columns
267
  display_df = dataframe[visible_columns].copy()
268
 
269
- print(f"--- DataFrame inside init_leaderboard (before rounding) ---")
270
- print(display_df[['model_name', 'macro_accuracy', 'macro_recall', 'total_evals_count']].head() if all(c in display_df.columns for c in ['model_name', 'macro_accuracy', 'macro_recall', 'total_evals_count']) else "Relevant columns not present")
271
- print(f"-------------------------------------------------------------")
272
 
273
  # Round numeric columns to 3 decimal places for display
274
  numeric_cols = display_df.select_dtypes(include=np.number).columns
@@ -338,7 +338,7 @@ def refresh_data_with_filters(version=CURRENT_VERSION, search_query="", model_ty
338
  # Get new data
339
  main_df = get_leaderboard_df(version=version)
340
  category_dfs = [get_category_leaderboard_df(category, version=version) for category in CATEGORIES]
341
- selected_columns = [x.lower().replace(" ", "_").replace("(", "").replace(")", "").replace("_recall", "_recall_binary") for x in selected_columns]
342
 
343
  # Log the actual columns we have
344
  logger.info(f"Main dataframe columns: {list(main_df.columns)}")
@@ -355,11 +355,16 @@ def refresh_data_with_filters(version=CURRENT_VERSION, search_query="", model_ty
355
 
356
  # Filter selected columns to only those available in the data
357
  if selected_columns:
358
- valid_selected_columns = [col for col in selected_columns if col in available_columns]
 
 
359
  if not valid_selected_columns and 'model_name' in available_columns:
360
- valid_selected_columns = ['model_name'] + get_default_visible_columns()
 
361
  else:
362
- valid_selected_columns = available_columns
 
 
363
 
364
  # Initialize dataframes for display with valid selected columns
365
  main_dataframe = init_leaderboard(filtered_main_df, valid_selected_columns)
@@ -675,7 +680,8 @@ with demo:
675
  selected_columns = get_default_visible_columns()
676
  logger.info(f"No columns selected, using defaults: {selected_columns}")
677
 
678
- selected_columns = [x.lower().replace(" ", "_").replace("(", "").replace(")", "").replace("_recall", "_recall_binary") for x in selected_columns]
 
679
 
680
 
681
  # Get the current data with ALL columns preserved
@@ -687,15 +693,15 @@ with demo:
687
 
688
  # Log columns for debugging
689
  logger.info(f"Main dataframe columns: {list(main_df.columns)}")
690
- logger.info(f"Selected columns: {selected_columns}")
691
 
692
  # IMPORTANT: Make sure model_name is always included
693
- if 'model_name' in main_df.columns and 'model_name' not in selected_columns:
694
- selected_columns = ['model_name'] + selected_columns
695
 
696
  # Initialize the main leaderboard with the selected columns
697
- # We're passing the raw selected_columns directly to preserve the selection
698
- main_leaderboard = init_leaderboard(main_df, selected_columns)
699
 
700
  # Initialize category dataframes with the same selected columns
701
  # This ensures consistency across all tabs
@@ -703,7 +709,7 @@ with demo:
703
  for df in category_dfs:
704
  # Use the same selected columns for each category
705
  # init_leaderboard will automatically handle filtering to columns that exist
706
- category_leaderboards.append(init_leaderboard(df, selected_columns))
707
 
708
  return main_leaderboard, *category_leaderboards
709
 
 
266
  visible_columns = ['model_name'] + visible_columns
267
  display_df = dataframe[visible_columns].copy()
268
 
269
+ # print(f"--- DataFrame inside init_leaderboard (before rounding) ---")
270
+ # print(display_df[['model_name', 'macro_accuracy', 'macro_recall', 'total_evals_count']].head() if all(c in display_df.columns for c in ['model_name', 'macro_accuracy', 'macro_recall', 'total_evals_count']) else "Relevant columns not present")
271
+ # print(f"-------------------------------------------------------------")
272
 
273
  # Round numeric columns to 3 decimal places for display
274
  numeric_cols = display_df.select_dtypes(include=np.number).columns
 
338
  # Get new data
339
  main_df = get_leaderboard_df(version=version)
340
  category_dfs = [get_category_leaderboard_df(category, version=version) for category in CATEGORIES]
341
+ selected_columns = [x.lower().replace(" ", "_").replace("(", "").replace(")", "").replace("_recall", "_recall_binary").replace("_precision", "_precision_binary") for x in selected_columns]
342
 
343
  # Log the actual columns we have
344
  logger.info(f"Main dataframe columns: {list(main_df.columns)}")
 
355
 
356
  # Filter selected columns to only those available in the data
357
  if selected_columns:
358
+ # Convert display names to internal names first
359
+ internal_selected_columns = [x.lower().replace(" ", "_").replace("(", "").replace(")", "").replace("_recall", "_recall_binary").replace("_precision", "_precision_binary") for x in selected_columns]
360
+ valid_selected_columns = [col for col in internal_selected_columns if col in available_columns]
361
  if not valid_selected_columns and 'model_name' in available_columns:
362
+ # Fallback if conversion/filtering leads to empty selection
363
+ valid_selected_columns = ['model_name'] + [col for col in get_default_visible_columns() if col in available_columns]
364
  else:
365
+ # If no columns were selected in the dropdown, use default visible columns that exist
366
+ valid_selected_columns = [col for col in get_default_visible_columns() if col in available_columns]
367
+
368
 
369
  # Initialize dataframes for display with valid selected columns
370
  main_dataframe = init_leaderboard(filtered_main_df, valid_selected_columns)
 
680
  selected_columns = get_default_visible_columns()
681
  logger.info(f"No columns selected, using defaults: {selected_columns}")
682
 
683
+ # Convert display names to internal names
684
+ internal_selected_columns = [x.lower().replace(" ", "_").replace("(", "").replace(")", "").replace("_recall", "_recall_binary").replace("_precision", "_precision_binary") for x in selected_columns]
685
 
686
 
687
  # Get the current data with ALL columns preserved
 
693
 
694
  # Log columns for debugging
695
  logger.info(f"Main dataframe columns: {list(main_df.columns)}")
696
+ logger.info(f"Selected columns (internal): {internal_selected_columns}")
697
 
698
  # IMPORTANT: Make sure model_name is always included
699
+ if 'model_name' in main_df.columns and 'model_name' not in internal_selected_columns:
700
+ internal_selected_columns = ['model_name'] + internal_selected_columns
701
 
702
  # Initialize the main leaderboard with the selected columns
703
+ # We're passing the internal_selected_columns directly to preserve the selection
704
+ main_leaderboard = init_leaderboard(main_df, internal_selected_columns)
705
 
706
  # Initialize category dataframes with the same selected columns
707
  # This ensures consistency across all tabs
 
709
  for df in category_dfs:
710
  # Use the same selected columns for each category
711
  # init_leaderboard will automatically handle filtering to columns that exist
712
+ category_leaderboards.append(init_leaderboard(df, internal_selected_columns))
713
 
714
  return main_leaderboard, *category_leaderboards
715