Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -214,19 +214,23 @@ with tab3:
|
|
214 |
if st.button("Convert to Binary Labels"):
|
215 |
common_cols = list(set(edited_df.columns) & set(thresholds.index))
|
216 |
numeric_cols = edited_df[common_cols].select_dtypes(include=[np.number]).columns.tolist()
|
217 |
-
|
218 |
binary_part = edited_df[numeric_cols].ge(thresholds[numeric_cols]).astype(int)
|
219 |
non_binary_part = edited_df.drop(columns=numeric_cols, errors='ignore')
|
220 |
binary_df = pd.concat([non_binary_part, binary_part], axis=1)
|
221 |
-
|
222 |
def highlight_binary(val):
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
|
|
226 |
styled_binary_df = binary_df.style.applymap(highlight_binary, subset=numeric_cols)
|
227 |
-
|
228 |
st.subheader("Binary Labels")
|
229 |
-
st.dataframe(styled_binary_df)
|
230 |
|
231 |
st.download_button(
|
232 |
label="Download Binary Labels Table as CSV",
|
@@ -234,3 +238,4 @@ with tab3:
|
|
234 |
file_name="ef_binary_labels_table.csv",
|
235 |
mime="text/csv"
|
236 |
)
|
|
|
|
214 |
if st.button("Convert to Binary Labels"):
|
215 |
common_cols = list(set(edited_df.columns) & set(thresholds.index))
|
216 |
numeric_cols = edited_df[common_cols].select_dtypes(include=[np.number]).columns.tolist()
|
217 |
+
|
218 |
binary_part = edited_df[numeric_cols].ge(thresholds[numeric_cols]).astype(int)
|
219 |
non_binary_part = edited_df.drop(columns=numeric_cols, errors='ignore')
|
220 |
binary_df = pd.concat([non_binary_part, binary_part], axis=1)
|
221 |
+
|
222 |
def highlight_binary(val):
|
223 |
+
if val == 1:
|
224 |
+
return 'background-color: lightgreen'
|
225 |
+
elif val == 0:
|
226 |
+
return 'background-color: lightcoral'
|
227 |
+
else:
|
228 |
+
return ''
|
229 |
+
|
230 |
styled_binary_df = binary_df.style.applymap(highlight_binary, subset=numeric_cols)
|
231 |
+
|
232 |
st.subheader("Binary Labels")
|
233 |
+
st.dataframe(styled_binary_df) # ✅ Display thresholded binary table
|
234 |
|
235 |
st.download_button(
|
236 |
label="Download Binary Labels Table as CSV",
|
|
|
238 |
file_name="ef_binary_labels_table.csv",
|
239 |
mime="text/csv"
|
240 |
)
|
241 |
+
|