de-Rodrigo commited on
Commit
69db70c
1 Parent(s): 71b912e

Include Max and Min Distances in Table

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -127,11 +127,27 @@ def create_table(df_distances):
127
  df_table = df_distances.copy()
128
  df_table.reset_index(inplace=True)
129
  df_table.rename(columns={'index': 'Synthetic'}, inplace=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  source_table = ColumnDataSource(df_table)
131
  columns = [TableColumn(field='Synthetic', title='Synthetic')]
132
  for col in df_table.columns:
133
  if col != 'Synthetic':
134
  columns.append(TableColumn(field=col, title=col))
 
135
  row_height = 28
136
  header_height = 30
137
  total_height = header_height + len(df_table) * row_height
@@ -139,6 +155,8 @@ def create_table(df_distances):
139
  data_table = DataTable(source=source_table, columns=columns, sizing_mode='stretch_width', height=total_height)
140
  return data_table, df_table, source_table
141
 
 
 
142
  # Funci贸n que ejecuta todo el proceso para un modelo determinado
143
  def run_model(model_name):
144
  embeddings = load_embeddings(model_name)
@@ -278,7 +296,7 @@ def run_model(model_name):
278
 
279
  # Agregar un bot贸n de descarga en Streamlit
280
  st.download_button(
281
- label="Exportar Table",
282
  data=buffer,
283
  file_name=f"cluster_distances_{model_name}.xlsx",
284
  mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
@@ -293,11 +311,11 @@ def main():
293
  tabs = st.tabs(["Donut", "Idefics2"])
294
 
295
  with tabs[0]:
296
- st.markdown('<h2 class="sub-title">Modelo Donut 馃</h2>', unsafe_allow_html=True)
297
  run_model("Donut")
298
 
299
  with tabs[1]:
300
- st.markdown('<h2 class="sub-title">Modelo Idefics2 馃</h2>', unsafe_allow_html=True)
301
  run_model("Idefics2")
302
 
303
  if __name__ == "__main__":
 
127
  df_table = df_distances.copy()
128
  df_table.reset_index(inplace=True)
129
  df_table.rename(columns={'index': 'Synthetic'}, inplace=True)
130
+
131
+ # Calcular las filas de medias, m谩ximos y m铆nimos para cada columna num茅rica
132
+ min_row = {"Synthetic": "Min."}
133
+ mean_row = {"Synthetic": "Mean"}
134
+ max_row = {"Synthetic": "Max."}
135
+
136
+ for col in df_table.columns:
137
+ if col != "Synthetic":
138
+ min_row[col] = df_table[col].min()
139
+ mean_row[col] = df_table[col].mean()
140
+ max_row[col] = df_table[col].max()
141
+
142
+ # Agregar las filas de medias, m谩ximos y m铆nimos al final del DataFrame
143
+ df_table = pd.concat([df_table, pd.DataFrame([min_row, mean_row, max_row])], ignore_index=True)
144
+
145
  source_table = ColumnDataSource(df_table)
146
  columns = [TableColumn(field='Synthetic', title='Synthetic')]
147
  for col in df_table.columns:
148
  if col != 'Synthetic':
149
  columns.append(TableColumn(field=col, title=col))
150
+
151
  row_height = 28
152
  header_height = 30
153
  total_height = header_height + len(df_table) * row_height
 
155
  data_table = DataTable(source=source_table, columns=columns, sizing_mode='stretch_width', height=total_height)
156
  return data_table, df_table, source_table
157
 
158
+
159
+
160
  # Funci贸n que ejecuta todo el proceso para un modelo determinado
161
  def run_model(model_name):
162
  embeddings = load_embeddings(model_name)
 
296
 
297
  # Agregar un bot贸n de descarga en Streamlit
298
  st.download_button(
299
+ label="Export Table",
300
  data=buffer,
301
  file_name=f"cluster_distances_{model_name}.xlsx",
302
  mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
 
311
  tabs = st.tabs(["Donut", "Idefics2"])
312
 
313
  with tabs[0]:
314
+ st.markdown('<h2 class="sub-title">Donut 馃</h2>', unsafe_allow_html=True)
315
  run_model("Donut")
316
 
317
  with tabs[1]:
318
+ st.markdown('<h2 class="sub-title">Idefics2 馃</h2>', unsafe_allow_html=True)
319
  run_model("Idefics2")
320
 
321
  if __name__ == "__main__":