mgyigit commited on
Commit
c0e572f
1 Parent(s): 8cc60a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -1
app.py CHANGED
@@ -45,6 +45,18 @@ def refresh_data():
45
  benchmark_types = ["similarity", "function", "family", "affinity"]
46
  download_from_hub(benchmark_types)
47
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  block = gr.Blocks()
49
 
50
  with block:
@@ -59,13 +71,27 @@ with block:
59
  metric_names = leaderboard.columns.tolist()
60
  metrics_with_method = metric_names.copy()
61
  metric_names.remove('Method') # Remove method_name from the metric options
 
 
 
 
 
 
 
62
 
63
  # Leaderboard section with method and metric selectors
64
  leaderboard_method_selector = gr.CheckboxGroup(
65
  choices=method_names, label="Select Methods for the Leaderboard", value=method_names, interactive=True
66
  )
 
 
 
 
 
 
 
67
  leaderboard_metric_selector = gr.CheckboxGroup(
68
- choices=metric_names, label="Select Metrics for the Leaderboard", value=metric_names, interactive=True
69
  )
70
 
71
  # Display the filtered leaderboard
@@ -89,6 +115,14 @@ with block:
89
  inputs=[leaderboard_method_selector, leaderboard_metric_selector],
90
  outputs=data_component
91
  )
 
 
 
 
 
 
 
 
92
  leaderboard_metric_selector.change(
93
  get_baseline_df,
94
  inputs=[leaderboard_method_selector, leaderboard_metric_selector],
 
45
  benchmark_types = ["similarity", "function", "family", "affinity"]
46
  download_from_hub(benchmark_types)
47
 
48
+ # Define a function to update metrics based on benchmark type selection
49
+ def update_metrics(selected_benchmarks):
50
+ updated_metrics = set()
51
+ for benchmark in selected_benchmarks:
52
+ updated_metrics.update(benchmark_metric_mapping.get(benchmark, []))
53
+ return list(updated_metrics)
54
+
55
+ # Define a function to update the leaderboard
56
+ def update_leaderboard(selected_methods, selected_metrics):
57
+ updated_df = get_baseline_df(selected_methods, selected_metrics)
58
+ return updated_df
59
+
60
  block = gr.Blocks()
61
 
62
  with block:
 
71
  metric_names = leaderboard.columns.tolist()
72
  metrics_with_method = metric_names.copy()
73
  metric_names.remove('Method') # Remove method_name from the metric options
74
+
75
+ benchmark_metric_mapping = {
76
+ "similarity": [metric for metric in metric_names if metric.startswith('sim_')],
77
+ "function": [metric for metric in metric_names if metric.startswith('func')],
78
+ "family": [metric for metric in metric_names if metric.startswith('fam_')],
79
+ "affinity": [metric for metric in metric_names if metric.startswith('aff_')],
80
+ }
81
 
82
  # Leaderboard section with method and metric selectors
83
  leaderboard_method_selector = gr.CheckboxGroup(
84
  choices=method_names, label="Select Methods for the Leaderboard", value=method_names, interactive=True
85
  )
86
+
87
+ benchmark_type_selector = gr.CheckboxGroup(
88
+ choices=list(benchmark_metric_mapping.keys()),
89
+ label="Select Benchmark Types",
90
+ value=None, # Initially select all benchmark types
91
+ interactive=True
92
+ )
93
  leaderboard_metric_selector = gr.CheckboxGroup(
94
+ choices=metric_names, label="Select Metrics for the Leaderboard", value=None, interactive=True
95
  )
96
 
97
  # Display the filtered leaderboard
 
115
  inputs=[leaderboard_method_selector, leaderboard_metric_selector],
116
  outputs=data_component
117
  )
118
+
119
+ # Update metrics when benchmark type changes
120
+ benchmark_type_selector.change(
121
+ lambda selected_benchmarks: update_metrics(selected_benchmarks),
122
+ inputs=[benchmark_type_selector],
123
+ outputs=leaderboard_metric_selector
124
+ )
125
+
126
  leaderboard_metric_selector.change(
127
  get_baseline_df,
128
  inputs=[leaderboard_method_selector, leaderboard_metric_selector],