de-Rodrigo commited on
Commit
6ff76c2
1 Parent(s): 554f351
Files changed (1) hide show
  1. app.py +32 -29
app.py CHANGED
@@ -1501,19 +1501,28 @@ def run_model(model_name):
1501
  feature_options = [col for col in df_heat.columns if col != "name"]
1502
  selected_feature = st.selectbox("Select heatmap feature:",
1503
  options=feature_options, key=f"heatmap_{model_name}")
1504
- # select_extra_dataset_hm = st.selectbox("Select a dataset:",
1505
- # options=model_options_with_default, key=f"heatmap_extra_dataset_{model_name}")
1506
-
1507
- # Definir un rango fijo y rejilla
1508
- x_min, x_max = -1, 1
1509
- y_min, y_max = -1, 1
1510
- grid_size = 50
1511
- x_bins = np.linspace(x_min, x_max, grid_size + 1)
1512
- y_bins = np.linspace(y_min, y_max, grid_size + 1)
1513
 
1514
  # Solo una combinaci贸n: TSNE1 vs TSNE2
1515
  x_comp, y_comp = "TSNE1", "TSNE2"
1516
  st.markdown(f"### Heatmap: {x_comp} vs {y_comp}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1517
 
1518
  df_heatmap = df_heatmap_base.copy()
1519
  df_heatmap["x"] = df_heatmap[x_comp]
@@ -1555,13 +1564,7 @@ def run_model(model_name):
1555
  nan_color='rgba(0, 0, 0, 0)'
1556
  )
1557
 
1558
- x_min, x_max = df_heatmap[x_comp].min(), df_heatmap[x_comp].max()
1559
- y_min, y_max = df_heatmap[y_comp].min(), df_heatmap[y_comp].max()
1560
-
1561
- # opcional: ampliar un poco para que no quede todo pegado al borde
1562
- padding = 0.05
1563
- x_range = (x_min - padding, x_max + padding)
1564
- y_range = (y_min - padding, y_max + padding)
1565
 
1566
  # Figura heatmap
1567
  heatmap_fig = figure(title=f"Heatmap de '{selected_feature}' ({x_comp} vs {y_comp})",
@@ -1603,19 +1606,19 @@ def run_model(model_name):
1603
  })
1604
  invisible_renderer = heatmap_fig.circle('x', 'y', size=10, source=source_points, fill_alpha=0, line_alpha=0.5)
1605
 
1606
- # if select_extra_dataset_hm != "-":
1607
- # df_extra = df_all["synthetic"][df_all["synthetic"]["source"] == select_extra_dataset_hm].copy()
1608
- # df_extra["x"] = df_extra[x_comp]
1609
- # df_extra["y"] = df_extra[y_comp]
1610
- # if 'name' not in df_extra.columns:
1611
- # df_extra["name"] = df_extra["img"].apply(lambda x: x.split("/")[-1].replace(".png", "") if isinstance(x, str) else x)
1612
- # source_extra_points = ColumnDataSource(data={
1613
- # 'x': df_extra['x'],
1614
- # 'y': df_extra['y'],
1615
- # 'img': df_extra['img'],
1616
- # 'label': df_extra['name']
1617
- # })
1618
- # heatmap_fig.circle('x', 'y', size=5, source=source_extra_points, fill_alpha=0, line_alpha=0.5, color="purple")
1619
 
1620
  hover_tool_points = HoverTool(renderers=[invisible_renderer], tooltips=TOOLTIPS)
1621
  heatmap_fig.add_tools(hover_tool_points)
 
1501
  feature_options = [col for col in df_heat.columns if col != "name"]
1502
  selected_feature = st.selectbox("Select heatmap feature:",
1503
  options=feature_options, key=f"heatmap_{model_name}")
1504
+ select_extra_dataset_hm = st.selectbox("Select a dataset:",
1505
+ options=model_options_with_default, key=f"heatmap_extra_dataset_{model_name}")
 
 
 
 
 
 
 
1506
 
1507
  # Solo una combinaci贸n: TSNE1 vs TSNE2
1508
  x_comp, y_comp = "TSNE1", "TSNE2"
1509
  st.markdown(f"### Heatmap: {x_comp} vs {y_comp}")
1510
+
1511
+ # Rango real de los datos
1512
+ x_min, x_max = df_heatmap[x_comp].min(), df_heatmap[x_comp].max()
1513
+ y_min, y_max = df_heatmap[y_comp].min(), df_heatmap[y_comp].max()
1514
+
1515
+ # Opcional: ampliar un poco
1516
+ padding = 0.05
1517
+ x_min, x_max = x_min - padding, x_max + padding
1518
+ y_min, y_max = y_min - padding, y_max + padding
1519
+
1520
+ # Definir rejilla
1521
+ grid_size = st.slider("Grid size (resoluci贸n del heatmap)", min_value=10, max_value=100, value=40, step=5)
1522
+ x_bins = np.linspace(x_min, x_max, grid_size + 1)
1523
+ y_bins = np.linspace(y_min, y_max, grid_size + 1)
1524
+ x_range = (x_min - padding, x_max + padding)
1525
+ y_range = (y_min - padding, y_max + padding)
1526
 
1527
  df_heatmap = df_heatmap_base.copy()
1528
  df_heatmap["x"] = df_heatmap[x_comp]
 
1564
  nan_color='rgba(0, 0, 0, 0)'
1565
  )
1566
 
1567
+
 
 
 
 
 
 
1568
 
1569
  # Figura heatmap
1570
  heatmap_fig = figure(title=f"Heatmap de '{selected_feature}' ({x_comp} vs {y_comp})",
 
1606
  })
1607
  invisible_renderer = heatmap_fig.circle('x', 'y', size=10, source=source_points, fill_alpha=0, line_alpha=0.5)
1608
 
1609
+ if select_extra_dataset_hm != "-":
1610
+ df_extra = df_all["synthetic"][df_all["synthetic"]["source"] == select_extra_dataset_hm].copy()
1611
+ df_extra["x"] = df_extra[x_comp]
1612
+ df_extra["y"] = df_extra[y_comp]
1613
+ if 'name' not in df_extra.columns:
1614
+ df_extra["name"] = df_extra["img"].apply(lambda x: x.split("/")[-1].replace(".png", "") if isinstance(x, str) else x)
1615
+ source_extra_points = ColumnDataSource(data={
1616
+ 'x': df_extra['x'],
1617
+ 'y': df_extra['y'],
1618
+ 'img': df_extra['img'],
1619
+ 'label': df_extra['name']
1620
+ })
1621
+ heatmap_fig.circle('x', 'y', size=5, source=source_extra_points, fill_alpha=0, line_alpha=0.5, color="purple")
1622
 
1623
  hover_tool_points = HoverTool(renderers=[invisible_renderer], tooltips=TOOLTIPS)
1624
  heatmap_fig.add_tools(hover_tool_points)