Mollel commited on
Commit
5a4b675
1 Parent(s): a323ffa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -27
app.py CHANGED
@@ -21,30 +21,6 @@ def extract_table_from_markdown(markdown_text, table_start):
21
  table_content.append(line)
22
  return '\n'.join(table_content)
23
 
24
- # def markdown_table_to_df(table_content):
25
- # """Convert markdown table to pandas DataFrame."""
26
- # # Split the table content into lines
27
- # lines = table_content.split('\n')
28
-
29
- # # Extract headers
30
- # headers = [h.strip() for h in lines[0].split('|') if h.strip()]
31
-
32
- # # Extract data
33
- # data = []
34
- # for line in lines[2:]: # Skip the header separator line
35
- # row = [cell.strip() for cell in line.split('|') if cell.strip()]
36
- # if row and len(row) == len(headers): # Ensure row has the correct number of columns
37
- # data.append(row)
38
-
39
- # # Create DataFrame
40
- # df = pd.DataFrame(data, columns=headers)
41
-
42
- # # Convert numeric columns to float
43
- # for col in df.columns:
44
- # if col not in ["Model Name", "Publisher", "Open?", "Basemodel", "Matryoshka"]:
45
- # df[col] = pd.to_numeric(df[col], errors='coerce')
46
-
47
- # return df
48
 
49
  def markdown_table_to_df(table_content):
50
  """Convert markdown table to pandas DataFrame."""
@@ -79,8 +55,29 @@ def setup_page():
79
  st.title("⚡ Swahili Text Embeddings Leaderboard (STEL)")
80
  st.image("https://raw.githubusercontent.com/username/repo/main/files/STEL.jpg", width=300)
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  def display_leaderboard(df):
83
- """Display the leaderboard."""
84
  st.header("📊 Leaderboard")
85
 
86
  # Determine which non-benchmark columns are present
@@ -93,13 +90,56 @@ def display_leaderboard(df):
93
  # Filter dataframe
94
  df_display = df[present_non_benchmark_cols + selected_columns]
95
 
96
- # Display dataframe
97
- st.dataframe(df_display.style.format("{:.4f}", subset=[col for col in df_display.columns if df_display[col].dtype == 'float64']))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  # Download buttons
100
  csv = df_display.to_csv(index=False)
101
  st.download_button(label="Download as CSV", data=csv, file_name="leaderboard.csv", mime="text/csv")
102
 
 
 
103
  def display_evaluation():
104
  """Display the evaluation section."""
105
  st.header("🧪 Evaluation")
 
21
  table_content.append(line)
22
  return '\n'.join(table_content)
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  def markdown_table_to_df(table_content):
26
  """Convert markdown table to pandas DataFrame."""
 
55
  st.title("⚡ Swahili Text Embeddings Leaderboard (STEL)")
56
  st.image("https://raw.githubusercontent.com/username/repo/main/files/STEL.jpg", width=300)
57
 
58
+ # def display_leaderboard(df):
59
+ # """Display the leaderboard."""
60
+ # st.header("📊 Leaderboard")
61
+
62
+ # # Determine which non-benchmark columns are present
63
+ # present_non_benchmark_cols = [col for col in POSSIBLE_NON_BENCHMARK_COLS if col in df.columns]
64
+
65
+ # # Add filters
66
+ # columns_to_filter = [col for col in df.columns if col not in present_non_benchmark_cols]
67
+ # selected_columns = st.multiselect("Select benchmarks to display:", columns_to_filter, default=columns_to_filter)
68
+
69
+ # # Filter dataframe
70
+ # df_display = df[present_non_benchmark_cols + selected_columns]
71
+
72
+ # # Display dataframe
73
+ # st.dataframe(df_display.style.format("{:.4f}", subset=[col for col in df_display.columns if df_display[col].dtype == 'float64']))
74
+
75
+ # # Download buttons
76
+ # csv = df_display.to_csv(index=False)
77
+ # st.download_button(label="Download as CSV", data=csv, file_name="leaderboard.csv", mime="text/csv")
78
+
79
  def display_leaderboard(df):
80
+ """Display the leaderboard with compact columns."""
81
  st.header("📊 Leaderboard")
82
 
83
  # Determine which non-benchmark columns are present
 
90
  # Filter dataframe
91
  df_display = df[present_non_benchmark_cols + selected_columns]
92
 
93
+ # Define column widths
94
+ col_widths = {
95
+ "Model Name": 200,
96
+ "Publisher": 100,
97
+ "Open?": 60,
98
+ "Basemodel": 150,
99
+ "Matryoshka": 80,
100
+ "Dimension": 80,
101
+ "Average": 80
102
+ }
103
+
104
+ # Set default width for benchmark columns
105
+ default_width = 80
106
+
107
+ # Custom CSS to make the table more compact
108
+ st.markdown("""
109
+ <style>
110
+ .streamlit-expanderHeader {
111
+ font-size: 1em;
112
+ }
113
+ .stDataFrame {
114
+ font-size: 0.8em;
115
+ }
116
+ .stDataFrame td, .stDataFrame th {
117
+ white-space: nowrap;
118
+ overflow: hidden;
119
+ text-overflow: ellipsis;
120
+ max-width: 200px;
121
+ }
122
+ </style>
123
+ """, unsafe_allow_html=True)
124
+
125
+ # Format the dataframe
126
+ df_styled = df_display.style.format({col: "{:.2f}" for col in df_display.columns if df_display[col].dtype in ['float64', 'int64']})
127
+
128
+ # Set column widths
129
+ df_styled.set_properties(**{
130
+ 'width': lambda x: f"{col_widths.get(x.name, default_width)}px",
131
+ 'max-width': lambda x: f"{col_widths.get(x.name, default_width)}px",
132
+ })
133
+
134
+ # Display the dataframe
135
+ st.dataframe(df_styled, height=400)
136
 
137
  # Download buttons
138
  csv = df_display.to_csv(index=False)
139
  st.download_button(label="Download as CSV", data=csv, file_name="leaderboard.csv", mime="text/csv")
140
 
141
+
142
+
143
  def display_evaluation():
144
  """Display the evaluation section."""
145
  st.header("🧪 Evaluation")