Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -22,18 +22,22 @@ def load_data(file_path):
|
|
22 |
# Function to style the DataFrame
|
23 |
def style_dataframe(df: pd.DataFrame):
|
24 |
df[RESULTS_COLUMN_NAME] = df.apply(lambda row: [row[SENTIMENT_COLUMN_NAME], row[UNDERSTANDING_COLUMN_NAME], row[PHRASEOLOGY_COLUMN_NAME]], axis=1)
|
25 |
-
|
26 |
# Insert the new column after the 'Average' column
|
27 |
cols = list(df.columns)
|
28 |
cols.insert(cols.index(AVERAGE_COLUMN_NAME) + 1, cols.pop(cols.index(RESULTS_COLUMN_NAME)))
|
29 |
df = df[cols]
|
30 |
-
|
31 |
# Create a color ramp using Seaborn
|
32 |
return df
|
33 |
|
34 |
def styler(df: pd.DataFrame):
|
35 |
palette = sns.color_palette("RdYlGn", as_cmap=True)
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
return styled_df
|
38 |
|
39 |
|
@@ -136,14 +140,15 @@ with tab1:
|
|
136 |
|
137 |
# Display the styled DataFrame
|
138 |
data = load_data('data.json')
|
139 |
-
|
|
|
140 |
data = data.sort_values(by=AVERAGE_COLUMN_NAME, ascending=False)
|
141 |
styled_df_show = style_dataframe(data)
|
142 |
styled_df_show = styler(styled_df_show)
|
143 |
|
144 |
st.data_editor(styled_df_show, column_config={
|
145 |
"Model": st.column_config.TextColumn("Model", help="Model name", width="large"),
|
146 |
-
"Params": st.column_config.NumberColumn("Params [B]"
|
147 |
AVERAGE_COLUMN_NAME: st.column_config.NumberColumn(AVERAGE_COLUMN_NAME),
|
148 |
RESULTS_COLUMN_NAME: st.column_config.BarChartColumn(
|
149 |
"Bar chart of results", help="Summary of the results of each task",
|
|
|
22 |
# Function to style the DataFrame
|
23 |
def style_dataframe(df: pd.DataFrame):
|
24 |
df[RESULTS_COLUMN_NAME] = df.apply(lambda row: [row[SENTIMENT_COLUMN_NAME], row[UNDERSTANDING_COLUMN_NAME], row[PHRASEOLOGY_COLUMN_NAME]], axis=1)
|
|
|
25 |
# Insert the new column after the 'Average' column
|
26 |
cols = list(df.columns)
|
27 |
cols.insert(cols.index(AVERAGE_COLUMN_NAME) + 1, cols.pop(cols.index(RESULTS_COLUMN_NAME)))
|
28 |
df = df[cols]
|
|
|
29 |
# Create a color ramp using Seaborn
|
30 |
return df
|
31 |
|
32 |
def styler(df: pd.DataFrame):
|
33 |
palette = sns.color_palette("RdYlGn", as_cmap=True)
|
34 |
+
# Apply reverse color gradient to the "Params" column
|
35 |
+
params_palette = sns.color_palette("RdYlGn_r", as_cmap=True) # Reversed RdYlGn palette
|
36 |
+
styled_df = df.style.background_gradient(cmap=palette, subset=[AVERAGE_COLUMN_NAME, SENTIMENT_COLUMN_NAME, PHRASEOLOGY_COLUMN_NAME, UNDERSTANDING_COLUMN_NAME]
|
37 |
+
).background_gradient(cmap=params_palette, subset=["Params"]
|
38 |
+
).set_properties(**{'text-align': 'center'}, subset=[AVERAGE_COLUMN_NAME, SENTIMENT_COLUMN_NAME, PHRASEOLOGY_COLUMN_NAME, UNDERSTANDING_COLUMN_NAME]
|
39 |
+
).format("{:.2f}".center(10), subset=[AVERAGE_COLUMN_NAME, SENTIMENT_COLUMN_NAME, PHRASEOLOGY_COLUMN_NAME, UNDERSTANDING_COLUMN_NAME]
|
40 |
+
).format("{:.1f}".center(10), subset=["Params"])
|
41 |
return styled_df
|
42 |
|
43 |
|
|
|
140 |
|
141 |
# Display the styled DataFrame
|
142 |
data = load_data('data.json')
|
143 |
+
|
144 |
+
data['Params'] = data['Params'].str.replace('B', '').astype(float)
|
145 |
data = data.sort_values(by=AVERAGE_COLUMN_NAME, ascending=False)
|
146 |
styled_df_show = style_dataframe(data)
|
147 |
styled_df_show = styler(styled_df_show)
|
148 |
|
149 |
st.data_editor(styled_df_show, column_config={
|
150 |
"Model": st.column_config.TextColumn("Model", help="Model name", width="large"),
|
151 |
+
"Params": st.column_config.NumberColumn("Params [B]"),
|
152 |
AVERAGE_COLUMN_NAME: st.column_config.NumberColumn(AVERAGE_COLUMN_NAME),
|
153 |
RESULTS_COLUMN_NAME: st.column_config.BarChartColumn(
|
154 |
"Bar chart of results", help="Summary of the results of each task",
|