JieRuan commited on
Commit
c46f5d5
·
verified ·
1 Parent(s): fa0bf47

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +60 -25
src/streamlit_app.py CHANGED
@@ -68,31 +68,66 @@ max_ranks = {col: df[f"{col}_rank"].max() for col in score_cols}
68
  # one page description
69
  st.markdown("## Leaderboard")
70
  # st.markdown("**Leaderboard:** higher scores shaded green; best models bolded.")
71
- # Build raw HTML table
72
- cols = ["Model"] + [f"T{i}" for i in range(1,12)] + ["Avg"]
73
- html = "<table style='border-collapse:collapse; width:100%; font-size:14px;'>"
74
- # header
75
- html += "<tr>" + "".join(f"<th style='padding:6px;'>{col}</th>" for col in cols) + "</tr>"
76
- # rows
77
- for _, row in df.iterrows():
78
- html += "<tr>"
79
- for col in cols:
80
- val = row[col]
81
- if col == "Model":
82
- html += f"<td style='padding:6px; text-align:left;'>{val}</td>"
83
- else:
84
- rank = int(row[f"{col}_rank"])
85
- norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
86
- # interpolate green (182,243,182) → white (255,255,255)
87
- r = int(255 - norm*(255-182))
88
- g = int(255 - norm*(255-243))
89
- b = 255
90
- bold = "font-weight:bold;" if rank == 1 else ""
91
- style = f"background-color:rgb({r},{g},{b}); padding:6px; {bold}"
92
- html += f"<td style='{style}'>{val}</td>"
93
- html += "</tr>"
94
- html += "</table>"
95
- st.markdown(html, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  pipeline_image = Image.open("src/pipeline.png")
98
  buffered2 = BytesIO()
 
68
  # one page description
69
  st.markdown("## Leaderboard")
70
  # st.markdown("**Leaderboard:** higher scores shaded green; best models bolded.")
71
+
72
+ tiers = ['F1', 'Accuracy']
73
+ selected_tier = st.selectbox('Select metric:', tiers)
74
+
75
+ if selected_tier == 'F1':
76
+ # Build raw HTML table
77
+ cols = ["Model"] + [f"T{i}" for i in range(1,12)] + ["Avg"]
78
+ html = "<table style='border-collapse:collapse; width:100%; font-size:14px;'>"
79
+ # header
80
+ html += "<tr>" + "".join(f"<th style='padding:6px;'>{col}</th>" for col in cols) + "</tr>"
81
+ # rows
82
+ for _, row in df.iterrows():
83
+ html += "<tr>"
84
+ for col in cols:
85
+ val = row[col]
86
+ if col == "Model":
87
+ html += f"<td style='padding:6px; text-align:left;'>{val}</td>"
88
+ else:
89
+ rank = int(row[f"{col}_rank"])
90
+ norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
91
+ # interpolate green (182,243,182) white (255,255,255)
92
+ r = int(255 - norm*(255-182))
93
+ g = int(255 - norm*(255-243))
94
+ b = 255
95
+ bold = "font-weight:bold;" if rank == 1 else ""
96
+ style = f"background-color:rgb({r},{g},{b}); padding:6px; {bold}"
97
+ html += f"<td style='{style}'>{val}</td>"
98
+ html += "</tr>"
99
+ html += "</table>"
100
+ st.markdown(html, unsafe_allow_html=True)
101
+ else:
102
+ # # Build raw HTML table
103
+ # cols = ["Model"] + [f"T{i}" for i in range(1,12)] + ["Avg"]
104
+ # html = "<table style='border-collapse:collapse; width:100%; font-size:14px;'>"
105
+ # # header
106
+ # html += "<tr>" + "".join(f"<th style='padding:6px;'>{col}</th>" for col in cols) + "</tr>"
107
+ # # rows
108
+ # for _, row in df.iterrows():
109
+ # html += "<tr>"
110
+ # for col in cols:
111
+ # val = row[col]
112
+ # if col == "Model":
113
+ # html += f"<td style='padding:6px; text-align:left;'>{val}</td>"
114
+ # else:
115
+ # rank = int(row[f"{col}_rank"])
116
+ # norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
117
+ # # interpolate green (182,243,182) → white (255,255,255)
118
+ # r = int(255 - norm*(255-182))
119
+ # g = int(255 - norm*(255-243))
120
+ # b = 255
121
+ # bold = "font-weight:bold;" if rank == 1 else ""
122
+ # style = f"background-color:rgb({r},{g},{b}); padding:6px; {bold}"
123
+ # html += f"<td style='{style}'>{val}</td>"
124
+ # html += "</tr>"
125
+ # html += "</table>"
126
+ # st.markdown(html, unsafe_allow_html=True)
127
+ st.markdown(...)
128
+
129
+
130
+
131
 
132
  pipeline_image = Image.open("src/pipeline.png")
133
  buffered2 = BytesIO()