Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,21 +13,21 @@ from src.bin.PROBE import run_probe
|
|
13 |
|
14 |
global data_component, filter_component
|
15 |
|
16 |
-
def get_baseline_df():
|
17 |
df = pd.read_csv(CSV_RESULT_PATH)
|
18 |
-
present_columns = ["
|
19 |
-
df = df[present_columns]
|
20 |
return df
|
21 |
|
22 |
# Function to create the plot
|
23 |
def create_plot(methods_selected, x_metric, y_metric):
|
24 |
df = pd.read_csv(CSV_RESULT_PATH)
|
25 |
-
filtered_df = df[df['
|
26 |
|
27 |
# Create a larger plot
|
28 |
plt.figure(figsize=(10, 8)) # Increase the figure size
|
29 |
for method in methods_selected:
|
30 |
-
method_data = filtered_df[filtered_df['
|
31 |
plt.plot(method_data[x_metric], method_data[y_metric], label=method, marker='o')
|
32 |
|
33 |
plt.xlabel(x_metric)
|
@@ -58,6 +58,10 @@ def add_new_eval(
|
|
58 |
results = run_probe(benchmark_type, representation_name, human_file, skempi_file, similarity_tasks, function_prediction_aspect, function_prediction_dataset, family_prediction_dataset)
|
59 |
return None
|
60 |
|
|
|
|
|
|
|
|
|
61 |
block = gr.Blocks()
|
62 |
|
63 |
with block:
|
@@ -67,44 +71,60 @@ with block:
|
|
67 |
# table jmmmu bench
|
68 |
with gr.TabItem("🏅 PROBE Benchmark", elem_id="probe-benchmark-tab-table", id=1):
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
# Add the visualizer components (Dropdown, Checkbox, Button, Image)
|
71 |
with gr.Row():
|
72 |
-
method_names = pd.read_csv(CSV_RESULT_PATH)['
|
73 |
metric_names = pd.read_csv(CSV_RESULT_PATH).columns.tolist()
|
74 |
-
metric_names.remove('
|
75 |
|
76 |
# Visualizer Controls: Smaller and underneath each other
|
77 |
with gr.Column(scale=1):
|
78 |
-
method_selector = gr.CheckboxGroup(choices=method_names, label="Select Methods", interactive=True)
|
79 |
x_metric_selector = gr.Dropdown(choices=metric_names, label="Select X-axis Metric", interactive=True)
|
80 |
y_metric_selector = gr.Dropdown(choices=metric_names, label="Select Y-axis Metric", interactive=True)
|
81 |
plot_button = gr.Button("Plot")
|
82 |
|
83 |
# Larger plot display
|
84 |
with gr.Column(scale=3):
|
85 |
-
output_plot = gr.Image(label="Plot", height=
|
86 |
|
87 |
plot_button.click(create_plot, inputs=[method_selector, x_metric_selector, y_metric_selector], outputs=output_plot)
|
88 |
-
|
89 |
-
# Now the rest of the UI elements as they were before
|
90 |
-
checkbox_group = gr.CheckboxGroup(
|
91 |
-
choices=TASK_INFO,
|
92 |
-
label="Benchmark Type",
|
93 |
-
interactive=True,
|
94 |
-
) # User can select the evaluation dimension
|
95 |
-
|
96 |
-
baseline_value = get_baseline_df()
|
97 |
-
baseline_header = ["method_name"] + checkbox_group.value
|
98 |
-
baseline_datatype = ['markdown'] + ['number'] * len(checkbox_group.value)
|
99 |
-
|
100 |
-
data_component = gr.components.Dataframe(
|
101 |
-
value=baseline_value,
|
102 |
-
headers=baseline_header,
|
103 |
-
type="pandas",
|
104 |
-
datatype=baseline_datatype,
|
105 |
-
interactive=False,
|
106 |
-
visible=True,
|
107 |
-
)
|
108 |
|
109 |
# table 5
|
110 |
with gr.TabItem("📝 About", elem_id="probe-benchmark-tab-table", id=2):
|
@@ -178,7 +198,7 @@ with block:
|
|
178 |
)
|
179 |
|
180 |
def refresh_data():
|
181 |
-
value = get_baseline_df()
|
182 |
return value
|
183 |
|
184 |
with gr.Row():
|
|
|
13 |
|
14 |
global data_component, filter_component
|
15 |
|
16 |
+
def get_baseline_df(selected_methods, selected_metrics):
|
17 |
df = pd.read_csv(CSV_RESULT_PATH)
|
18 |
+
present_columns = ["Method"] + selected_metrics
|
19 |
+
df = df[df['Method'].isin(selected_methods)][present_columns]
|
20 |
return df
|
21 |
|
22 |
# Function to create the plot
|
23 |
def create_plot(methods_selected, x_metric, y_metric):
|
24 |
df = pd.read_csv(CSV_RESULT_PATH)
|
25 |
+
filtered_df = df[df['Method'].isin(methods_selected)]
|
26 |
|
27 |
# Create a larger plot
|
28 |
plt.figure(figsize=(10, 8)) # Increase the figure size
|
29 |
for method in methods_selected:
|
30 |
+
method_data = filtered_df[filtered_df['Method'] == method]
|
31 |
plt.plot(method_data[x_metric], method_data[y_metric], label=method, marker='o')
|
32 |
|
33 |
plt.xlabel(x_metric)
|
|
|
58 |
results = run_probe(benchmark_type, representation_name, human_file, skempi_file, similarity_tasks, function_prediction_aspect, function_prediction_dataset, family_prediction_dataset)
|
59 |
return None
|
60 |
|
61 |
+
# Function to update leaderboard dynamically based on user selection
|
62 |
+
def update_leaderboard(selected_methods, selected_metrics):
|
63 |
+
return get_baseline_df(selected_methods, selected_metrics)
|
64 |
+
|
65 |
block = gr.Blocks()
|
66 |
|
67 |
with block:
|
|
|
71 |
# table jmmmu bench
|
72 |
with gr.TabItem("🏅 PROBE Benchmark", elem_id="probe-benchmark-tab-table", id=1):
|
73 |
|
74 |
+
# Leaderboard section with method and metric selectors
|
75 |
+
with gr.Row():
|
76 |
+
# Add method and metric selectors for leaderboard
|
77 |
+
leaderboard_method_selector = gr.CheckboxGroup(
|
78 |
+
choices=method_names, label="Select Methods for Leaderboard", value=method_names, interactive=True
|
79 |
+
)
|
80 |
+
leaderboard_metric_selector = gr.CheckboxGroup(
|
81 |
+
choices=metric_names, label="Select Metrics for Leaderboard", value=metric_names, interactive=True
|
82 |
+
)
|
83 |
+
|
84 |
+
# Display the filtered leaderboard
|
85 |
+
baseline_value = get_baseline_df(method_names, metric_names)
|
86 |
+
baseline_header = ["Method"] + metric_names
|
87 |
+
baseline_datatype = ['markdown'] + ['number'] * len(metric_names)
|
88 |
+
|
89 |
+
data_component = gr.components.Dataframe(
|
90 |
+
value=baseline_value,
|
91 |
+
headers=baseline_header,
|
92 |
+
type="pandas",
|
93 |
+
datatype=baseline_datatype,
|
94 |
+
interactive=False,
|
95 |
+
visible=True,
|
96 |
+
)
|
97 |
+
|
98 |
+
# Update leaderboard when method/metric selection changes
|
99 |
+
leaderboard_method_selector.change(
|
100 |
+
update_leaderboard,
|
101 |
+
inputs=[leaderboard_method_selector, leaderboard_metric_selector],
|
102 |
+
outputs=data_component
|
103 |
+
)
|
104 |
+
leaderboard_metric_selector.change(
|
105 |
+
update_leaderboard,
|
106 |
+
inputs=[leaderboard_method_selector, leaderboard_metric_selector],
|
107 |
+
outputs=data_component
|
108 |
+
)
|
109 |
+
|
110 |
# Add the visualizer components (Dropdown, Checkbox, Button, Image)
|
111 |
with gr.Row():
|
112 |
+
method_names = pd.read_csv(CSV_RESULT_PATH)['Method'].unique().tolist()
|
113 |
metric_names = pd.read_csv(CSV_RESULT_PATH).columns.tolist()
|
114 |
+
metric_names.remove('Method') # Remove Method from the metric options
|
115 |
|
116 |
# Visualizer Controls: Smaller and underneath each other
|
117 |
with gr.Column(scale=1):
|
118 |
+
method_selector = gr.CheckboxGroup(choices=method_names, label="Select Methods", interactive=True, value=method_names)
|
119 |
x_metric_selector = gr.Dropdown(choices=metric_names, label="Select X-axis Metric", interactive=True)
|
120 |
y_metric_selector = gr.Dropdown(choices=metric_names, label="Select Y-axis Metric", interactive=True)
|
121 |
plot_button = gr.Button("Plot")
|
122 |
|
123 |
# Larger plot display
|
124 |
with gr.Column(scale=3):
|
125 |
+
output_plot = gr.Image(label="Plot", height=600) # Set larger height for the plot
|
126 |
|
127 |
plot_button.click(create_plot, inputs=[method_selector, x_metric_selector, y_metric_selector], outputs=output_plot)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
# table 5
|
130 |
with gr.TabItem("📝 About", elem_id="probe-benchmark-tab-table", id=2):
|
|
|
198 |
)
|
199 |
|
200 |
def refresh_data():
|
201 |
+
value = get_baseline_df(method_names, metric_names)
|
202 |
return value
|
203 |
|
204 |
with gr.Row():
|