JieRuan commited on
Commit
b530127
·
verified ·
1 Parent(s): bf679b5

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +31 -26
src/streamlit_app.py CHANGED
@@ -100,32 +100,37 @@ if selected_tier == 'F1':
100
  html += "</table>"
101
  st.markdown(html, unsafe_allow_html=True)
102
  else:
103
- # # Build raw HTML table
104
- # cols = ["Model"] + [f"T{i}" for i in range(1,12)] + ["Avg"]
105
- # html = "<table style='border-collapse:collapse; width:100%; font-size:14px;'>"
106
- # # header
107
- # html += "<tr>" + "".join(f"<th style='padding:6px;'>{col}</th>" for col in cols) + "</tr>"
108
- # # rows
109
- # for _, row in df.iterrows():
110
- # html += "<tr>"
111
- # for col in cols:
112
- # val = row[col]
113
- # if col == "Model":
114
- # html += f"<td style='padding:6px; text-align:left;'>{val}</td>"
115
- # else:
116
- # rank = int(row[f"{col}_rank"])
117
- # norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
118
- # # interpolate green (182,243,182) → white (255,255,255)
119
- # r = int(255 - norm*(255-182))
120
- # g = int(255 - norm*(255-243))
121
- # b = 255
122
- # bold = "font-weight:bold;" if rank == 1 else ""
123
- # style = f"background-color:rgb({r},{g},{b}); padding:6px; {bold}"
124
- # html += f"<td style='{style}'>{val}</td>"
125
- # html += "</tr>"
126
- # html += "</table>"
127
- # st.markdown(html, unsafe_allow_html=True)
128
- st.markdown(...)
 
 
 
 
 
129
 
130
 
131
 
 
100
  html += "</table>"
101
  st.markdown(html, unsafe_allow_html=True)
102
  else:
103
+ df = load_data("src/model_acc.json")
104
+
105
+ # Precompute max ranks for color scaling
106
+ score_cols = [f"T{i}" for i in range(1, 12)] + ["Avg"]
107
+ max_ranks = {col: df[f"{col}_rank"].max() for col in score_cols}
108
+ # Build raw HTML table
109
+ cols = ["Model"] + [f"T{i}" for i in range(1,12)] + ["Avg"]
110
+ html = "<table style='border-collapse:collapse; width:100%; font-size:14px;'>"
111
+ # header
112
+ html += "<tr>" + "".join(f"<th style='padding:6px;'>{col}</th>" for col in cols) + "</tr>"
113
+ # rows
114
+ for _, row in df.iterrows():
115
+ html += "<tr>"
116
+ for col in cols:
117
+ val = row[col]
118
+ if col == "Model":
119
+ html += f"<td style='padding:6px; text-align:left;'>{val}</td>"
120
+ else:
121
+ rank = int(row[f"{col}_rank"])
122
+ norm = 1 - (rank - 1) / ((max_ranks[col] - 1) or 1)
123
+ # interpolate green (182,243,182) white (255,255,255)
124
+ r = int(255 - norm*(255-182))
125
+ g = int(255 - norm*(255-243))
126
+ b = 255
127
+ bold = "font-weight:bold;" if rank == 1 else ""
128
+ style = f"background-color:rgb({r},{g},{b}); padding:6px; {bold}"
129
+ html += f"<td style='{style}'>{val}</td>"
130
+ html += "</tr>"
131
+ html += "</table>"
132
+ st.markdown(html, unsafe_allow_html=True)
133
+
134
 
135
 
136