|
|
|
import gradio as gr |
|
import pandas as pd |
|
|
|
|
|
uc_result_df = pd.read_csv('uc_result.csv') |
|
|
|
|
|
percentage_columns = [col for col in uc_result_df.columns if uc_result_df[col].dtype == 'object' and '%' in uc_result_df[col].iloc[0]] |
|
for col in percentage_columns: |
|
uc_result_df[col] = uc_result_df[col].str.rstrip('%').astype('float') / 100 |
|
|
|
|
|
def filter_and_sort(method=None, sort_by=None, ascending=True): |
|
filtered_df = uc_result_df |
|
if method: |
|
filtered_df = filtered_df[filtered_df['Method'].str.contains(method)] |
|
if sort_by: |
|
filtered_df = filtered_df.sort_values(by=sort_by, ascending=ascending) |
|
return filtered_df |
|
|
|
|
|
method_input = gr.inputs.Textbox(label="Filter by Method", placeholder="Enter method name...") |
|
sort_by_dropdown = gr.inputs.Dropdown(label="Sort by", choices=uc_result_df.columns.tolist(), default=None) |
|
ascending_checkbox = gr.inputs.Checkbox(label="Ascending Order", value=True) |
|
|
|
|
|
iface = gr.Interface( |
|
fn=filter_and_sort, |
|
inputs=[method_input, sort_by_dropdown, ascending_checkbox], |
|
outputs=gr.outputs.DataFrame(type="pandas"), |
|
title="Enhanced UC Results Display", |
|
description="This interface allows filtering and sorting of the results from uc_result.csv" |
|
) |
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|