Spaces:
Sleeping
Sleeping
Commit
·
97acf89
1
Parent(s):
653511a
Try Again
Browse files
app.py
CHANGED
|
@@ -1072,7 +1072,6 @@ def run_model(model_name):
|
|
| 1072 |
)
|
| 1073 |
|
| 1074 |
reduced_real = reducer_real.fit_transform(df_real_only[embedding_cols].values)
|
| 1075 |
-
reduced_real = np.nan_to_num(reduced_real).astype(float)
|
| 1076 |
|
| 1077 |
# Agregar columnas PC1, PC2, … a df_real_only
|
| 1078 |
for i in range(reduced_real.shape[1]):
|
|
@@ -1547,6 +1546,16 @@ def run_model(model_name):
|
|
| 1547 |
# Transponer y limpiar valores inválidos (NaN, inf, -inf)
|
| 1548 |
heatmap_data = heat_stat.T
|
| 1549 |
# heatmap_data = np.nan_to_num(heat_stat.T, nan=0.0, posinf=0.0, neginf=0.0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1550 |
|
| 1551 |
# Definir el color mapper
|
| 1552 |
if selected_feature in model_options:
|
|
@@ -1580,9 +1589,17 @@ def run_model(model_name):
|
|
| 1580 |
heatmap_fig.border_fill_color = "white"
|
| 1581 |
|
| 1582 |
# Dibujar la imagen del heatmap
|
| 1583 |
-
|
| 1584 |
-
|
| 1585 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1586 |
|
| 1587 |
# Agregar la barra de color
|
| 1588 |
color_bar = ColorBar(color_mapper=color_mapper, location=(0, 0))
|
|
|
|
| 1072 |
)
|
| 1073 |
|
| 1074 |
reduced_real = reducer_real.fit_transform(df_real_only[embedding_cols].values)
|
|
|
|
| 1075 |
|
| 1076 |
# Agregar columnas PC1, PC2, … a df_real_only
|
| 1077 |
for i in range(reduced_real.shape[1]):
|
|
|
|
| 1546 |
# Transponer y limpiar valores inválidos (NaN, inf, -inf)
|
| 1547 |
heatmap_data = heat_stat.T
|
| 1548 |
# heatmap_data = np.nan_to_num(heat_stat.T, nan=0.0, posinf=0.0, neginf=0.0)
|
| 1549 |
+
|
| 1550 |
+
if reduction_method == "UMAP":
|
| 1551 |
+
nan_mask = np.isnan(heatmap_data)
|
| 1552 |
+
valid_min = np.nanmin(heatmap_data)
|
| 1553 |
+
heatmap_data = np.nan_to_num(heatmap_data, nan=valid_min, posinf=valid_min, neginf=valid_min)
|
| 1554 |
+
heatmap_data = heatmap_data.astype(float)
|
| 1555 |
+
|
| 1556 |
+
if nan_mask.any():
|
| 1557 |
+
transparent_layer = np.zeros_like(heatmap_data)
|
| 1558 |
+
transparent_layer[~nan_mask] = np.nan
|
| 1559 |
|
| 1560 |
# Definir el color mapper
|
| 1561 |
if selected_feature in model_options:
|
|
|
|
| 1589 |
heatmap_fig.border_fill_color = "white"
|
| 1590 |
|
| 1591 |
# Dibujar la imagen del heatmap
|
| 1592 |
+
if reduction_method == "PCA":
|
| 1593 |
+
heatmap_fig.image(image=[heatmap_data], x=x_min, y=y_min,
|
| 1594 |
+
dw=x_max - x_min, dh=y_max - y_min,
|
| 1595 |
+
color_mapper=color_mapper)
|
| 1596 |
+
else:
|
| 1597 |
+
heatmap_fig.image(
|
| 1598 |
+
image=[transparent_layer],
|
| 1599 |
+
x=x_min, y=y_min,
|
| 1600 |
+
dw=x_max - x_min, dh=y_max - y_min,
|
| 1601 |
+
color_mapper=color_mapper
|
| 1602 |
+
)
|
| 1603 |
|
| 1604 |
# Agregar la barra de color
|
| 1605 |
color_bar = ColorBar(color_mapper=color_mapper, location=(0, 0))
|