delete due to wrong path
Browse files- summarization.py +0 -127
summarization.py
DELETED
@@ -1,127 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import pandas as pd
|
3 |
-
import numpy as np
|
4 |
-
from streamlit_echarts import st_echarts
|
5 |
-
from streamlit.components.v1 import html
|
6 |
-
# from PIL import Image
|
7 |
-
from app.show_examples import *
|
8 |
-
from app.content import *
|
9 |
-
|
10 |
-
import pandas as pd
|
11 |
-
from typing import List
|
12 |
-
|
13 |
-
from model_information import get_dataframe
|
14 |
-
|
15 |
-
info_df = get_dataframe()
|
16 |
-
|
17 |
-
|
18 |
-
def sum_table_mulit_metrix(task_name, metrics_lists: List[str]):
|
19 |
-
|
20 |
-
# combine chart data from multiple sources
|
21 |
-
chart_data = pd.DataFrame()
|
22 |
-
for metrics in metrics_lists:
|
23 |
-
folder = f"./results_organized/{metrics}"
|
24 |
-
data_path = f'{folder}/{task_name.lower()}.csv'
|
25 |
-
one_chart_data = pd.read_csv(data_path).round(3)
|
26 |
-
if len(chart_data) == 0:
|
27 |
-
chart_data = one_chart_data
|
28 |
-
else:
|
29 |
-
chart_data = pd.merge(chart_data, one_chart_data, on='Model', how='outer')
|
30 |
-
|
31 |
-
|
32 |
-
selected_columns = [i for i in chart_data.columns if i != 'Model']
|
33 |
-
chart_data['Average'] = chart_data[selected_columns].mean(axis=1)
|
34 |
-
|
35 |
-
# Update dataset name in table
|
36 |
-
chart_data = chart_data.rename(columns=datasetname2diaplayname)
|
37 |
-
|
38 |
-
st.markdown("""
|
39 |
-
<style>
|
40 |
-
.stMultiSelect [data-baseweb=select] span {
|
41 |
-
max-width: 800px;
|
42 |
-
font-size: 0.9rem;
|
43 |
-
background-color: #3C6478 !important; /* Background color for selected items */
|
44 |
-
color: white; /* Change text color */
|
45 |
-
back
|
46 |
-
}
|
47 |
-
</style>
|
48 |
-
""", unsafe_allow_html=True)
|
49 |
-
|
50 |
-
# remap model names
|
51 |
-
display_model_names = {key.strip() :val.strip() for key, val in zip(info_df['Original Name'], info_df['Proper Display Name'])}
|
52 |
-
chart_data['model_show'] = chart_data['Model'].map(lambda x: display_model_names.get(x, x))
|
53 |
-
|
54 |
-
models = st.multiselect("Please choose the model",
|
55 |
-
sorted(chart_data['model_show'].tolist()),
|
56 |
-
default = sorted(chart_data['model_show'].tolist()),
|
57 |
-
)
|
58 |
-
|
59 |
-
chart_data = chart_data[chart_data['model_show'].isin(models)].dropna(axis=0)
|
60 |
-
|
61 |
-
if len(chart_data) == 0: return
|
62 |
-
|
63 |
-
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
64 |
-
'''
|
65 |
-
Show Table
|
66 |
-
'''
|
67 |
-
with st.container():
|
68 |
-
st.markdown(f'##### TABLE')
|
69 |
-
|
70 |
-
model_link = {key.strip(): val for key, val in zip(info_df['Proper Display Name'], info_df['Link'])}
|
71 |
-
|
72 |
-
chart_data['model_link'] = chart_data['model_show'].map(model_link)
|
73 |
-
|
74 |
-
tabel_columns = [i for i in chart_data.columns if i not in ['Model', 'model_show']]
|
75 |
-
column_to_front = 'Average'
|
76 |
-
new_order = [column_to_front] + [col for col in tabel_columns if col != column_to_front]
|
77 |
-
|
78 |
-
chart_data_table = chart_data[['model_show'] + new_order]
|
79 |
-
|
80 |
-
|
81 |
-
# Format numeric columns to 2 decimal places
|
82 |
-
chart_data_table[chart_data_table.columns[1]] = chart_data_table[chart_data_table.columns[1]].apply(lambda x: round(float(x), 3) if isinstance(float(x), (int, float)) else float(x))
|
83 |
-
|
84 |
-
if metrics in ['wer']:
|
85 |
-
ascend = True
|
86 |
-
else:
|
87 |
-
ascend= False
|
88 |
-
|
89 |
-
chart_data_table = chart_data_table.sort_values(
|
90 |
-
by=['Average'],
|
91 |
-
ascending=ascend
|
92 |
-
).reset_index(drop=True)
|
93 |
-
|
94 |
-
# Highlight the best performing model
|
95 |
-
def highlight_first_element(x):
|
96 |
-
# Create a DataFrame with the same shape as the input
|
97 |
-
df_style = pd.DataFrame('', index=x.index, columns=x.columns)
|
98 |
-
# Apply background color to the first element in row 0 (df[0][0])
|
99 |
-
# df_style.iloc[0, 1] = 'background-color: #b0c1d7; color: white'
|
100 |
-
df_style.iloc[0, 1] = 'background-color: #b0c1d7'
|
101 |
-
|
102 |
-
return df_style
|
103 |
-
|
104 |
-
|
105 |
-
styled_df = chart_data_table.style.format(
|
106 |
-
{
|
107 |
-
chart_data_table.columns[i]: "{:.3f}" for i in range(1, len(chart_data_table.columns) - 1)
|
108 |
-
}
|
109 |
-
).apply(
|
110 |
-
highlight_first_element, axis=None
|
111 |
-
)
|
112 |
-
|
113 |
-
st.dataframe(
|
114 |
-
styled_df,
|
115 |
-
column_config={
|
116 |
-
'model_show': 'Model',
|
117 |
-
chart_data_table.columns[1]: {'alignment': 'left'},
|
118 |
-
"model_link": st.column_config.LinkColumn(
|
119 |
-
"Model Link",
|
120 |
-
),
|
121 |
-
},
|
122 |
-
hide_index=True,
|
123 |
-
use_container_width=True
|
124 |
-
)
|
125 |
-
|
126 |
-
# Only report the last metrics
|
127 |
-
st.markdown(f'###### Metric: {metrics_info[metrics]}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|