Roni Goldshmidt
commited on
Commit
·
d4ae493
1
Parent(s):
be4ab9e
Initial leaderboard setup
Browse files- .ipynb_checkpoints/app-checkpoint.py +51 -23
- app.py +51 -23
.ipynb_checkpoints/app-checkpoint.py
CHANGED
@@ -79,31 +79,59 @@ def style_dataframe(df, highlight_first_column=True, show_progress_bars=True):
|
|
79 |
# Start with basic formatting
|
80 |
styled = df.style.format({col: '{:.2f}%' for col in numeric_cols})
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
styles = []
|
91 |
-
for val, norm_val in zip(data, normalized):
|
92 |
-
style = []
|
93 |
-
if show_progress_bars:
|
94 |
-
style.append(f'background-color: rgba({int(255 * (1 - norm_val))}, {int(255 * norm_val)}, 0, 0.2)')
|
95 |
-
if highlight_first_column and column == first_numeric_col:
|
96 |
-
style.append('background-color: rgba(74, 144, 226, 0.2)')
|
97 |
-
style.append('font-weight: bold')
|
98 |
-
styles.append('; '.join(style) if style else '')
|
99 |
-
|
100 |
-
return styles
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
-
# Apply basic styling
|
107 |
styled = styled.set_properties(**{
|
108 |
'padding': '10px',
|
109 |
'border': '1px solid #dee2e6',
|
|
|
79 |
# Start with basic formatting
|
80 |
styled = df.style.format({col: '{:.2f}%' for col in numeric_cols})
|
81 |
|
82 |
+
if show_progress_bars:
|
83 |
+
styled = styled.background_gradient(
|
84 |
+
cmap='RdYlGn', # Red to Yellow to Green colormap
|
85 |
+
subset=numeric_cols,
|
86 |
+
vmin=0,
|
87 |
+
vmax=100
|
88 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
+
if highlight_first_column and first_numeric_col:
|
91 |
+
styled = styled.set_properties(
|
92 |
+
subset=[first_numeric_col],
|
93 |
+
**{'font-weight': 'bold', 'border-left': '2px solid #4a90e2', 'border-right': '2px solid #4a90e2'}
|
94 |
+
)
|
95 |
+
|
96 |
+
styled = styled.set_properties(**{
|
97 |
+
'padding': '10px',
|
98 |
+
'border': '1px solid #dee2e6',
|
99 |
+
'text-align': 'center'
|
100 |
+
})
|
101 |
+
|
102 |
+
styled = styled.set_table_styles([
|
103 |
+
{'selector': 'th', 'props': [
|
104 |
+
('background-color', '#4a90e2'),
|
105 |
+
('color', 'white'),
|
106 |
+
('font-weight', 'bold'),
|
107 |
+
('padding', '10px'),
|
108 |
+
('text-align', 'center')
|
109 |
+
]},
|
110 |
+
{'selector': 'tr:hover', 'props': [
|
111 |
+
('background-color', '#edf2f7')
|
112 |
+
]}
|
113 |
+
])
|
114 |
+
|
115 |
+
return styled
|
116 |
+
|
117 |
+
def style_comparison_dataframe(df):
|
118 |
+
"""Style dataframe specifically for model comparison tables"""
|
119 |
+
numeric_cols = [col for col in df.columns if col not in ['Class', 'Difference']]
|
120 |
+
|
121 |
+
styled = df.style.format({
|
122 |
+
**{col: '{:.2f}%' for col in numeric_cols},
|
123 |
+
'Difference': '{:+.2f}%' # Add plus sign for positive values
|
124 |
+
})
|
125 |
+
|
126 |
+
# Apply red-green gradient only to Difference column
|
127 |
+
if 'Difference' in df.columns:
|
128 |
+
styled = styled.background_gradient(
|
129 |
+
cmap='RdYlGn',
|
130 |
+
subset=['Difference'],
|
131 |
+
vmin=-10, # -10% difference
|
132 |
+
vmax=10 # +10% difference
|
133 |
+
)
|
134 |
|
|
|
135 |
styled = styled.set_properties(**{
|
136 |
'padding': '10px',
|
137 |
'border': '1px solid #dee2e6',
|
app.py
CHANGED
@@ -79,31 +79,59 @@ def style_dataframe(df, highlight_first_column=True, show_progress_bars=True):
|
|
79 |
# Start with basic formatting
|
80 |
styled = df.style.format({col: '{:.2f}%' for col in numeric_cols})
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
styles = []
|
91 |
-
for val, norm_val in zip(data, normalized):
|
92 |
-
style = []
|
93 |
-
if show_progress_bars:
|
94 |
-
style.append(f'background-color: rgba({int(255 * (1 - norm_val))}, {int(255 * norm_val)}, 0, 0.2)')
|
95 |
-
if highlight_first_column and column == first_numeric_col:
|
96 |
-
style.append('background-color: rgba(74, 144, 226, 0.2)')
|
97 |
-
style.append('font-weight: bold')
|
98 |
-
styles.append('; '.join(style) if style else '')
|
99 |
-
|
100 |
-
return styles
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
-
# Apply basic styling
|
107 |
styled = styled.set_properties(**{
|
108 |
'padding': '10px',
|
109 |
'border': '1px solid #dee2e6',
|
|
|
79 |
# Start with basic formatting
|
80 |
styled = df.style.format({col: '{:.2f}%' for col in numeric_cols})
|
81 |
|
82 |
+
if show_progress_bars:
|
83 |
+
styled = styled.background_gradient(
|
84 |
+
cmap='RdYlGn', # Red to Yellow to Green colormap
|
85 |
+
subset=numeric_cols,
|
86 |
+
vmin=0,
|
87 |
+
vmax=100
|
88 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
+
if highlight_first_column and first_numeric_col:
|
91 |
+
styled = styled.set_properties(
|
92 |
+
subset=[first_numeric_col],
|
93 |
+
**{'font-weight': 'bold', 'border-left': '2px solid #4a90e2', 'border-right': '2px solid #4a90e2'}
|
94 |
+
)
|
95 |
+
|
96 |
+
styled = styled.set_properties(**{
|
97 |
+
'padding': '10px',
|
98 |
+
'border': '1px solid #dee2e6',
|
99 |
+
'text-align': 'center'
|
100 |
+
})
|
101 |
+
|
102 |
+
styled = styled.set_table_styles([
|
103 |
+
{'selector': 'th', 'props': [
|
104 |
+
('background-color', '#4a90e2'),
|
105 |
+
('color', 'white'),
|
106 |
+
('font-weight', 'bold'),
|
107 |
+
('padding', '10px'),
|
108 |
+
('text-align', 'center')
|
109 |
+
]},
|
110 |
+
{'selector': 'tr:hover', 'props': [
|
111 |
+
('background-color', '#edf2f7')
|
112 |
+
]}
|
113 |
+
])
|
114 |
+
|
115 |
+
return styled
|
116 |
+
|
117 |
+
def style_comparison_dataframe(df):
|
118 |
+
"""Style dataframe specifically for model comparison tables"""
|
119 |
+
numeric_cols = [col for col in df.columns if col not in ['Class', 'Difference']]
|
120 |
+
|
121 |
+
styled = df.style.format({
|
122 |
+
**{col: '{:.2f}%' for col in numeric_cols},
|
123 |
+
'Difference': '{:+.2f}%' # Add plus sign for positive values
|
124 |
+
})
|
125 |
+
|
126 |
+
# Apply red-green gradient only to Difference column
|
127 |
+
if 'Difference' in df.columns:
|
128 |
+
styled = styled.background_gradient(
|
129 |
+
cmap='RdYlGn',
|
130 |
+
subset=['Difference'],
|
131 |
+
vmin=-10, # -10% difference
|
132 |
+
vmax=10 # +10% difference
|
133 |
+
)
|
134 |
|
|
|
135 |
styled = styled.set_properties(**{
|
136 |
'padding': '10px',
|
137 |
'border': '1px solid #dee2e6',
|