Spaces:
Running
Running
Commit
·
c6959dd
1
Parent(s):
4f6b962
Revert "Revert "Choose t-sne or PCA""
Browse filesThis reverts commit 6071181bfa738ccb89f21fbfc4f518d9ca0ef7e0.
app.py
CHANGED
@@ -4,7 +4,6 @@ from bokeh.plotting import figure
|
|
4 |
from bokeh.models import ColumnDataSource
|
5 |
from bokeh.palettes import Category10
|
6 |
|
7 |
-
|
8 |
TOOLTIPS = """
|
9 |
<div>
|
10 |
<div>
|
@@ -16,7 +15,6 @@ TOOLTIPS = """
|
|
16 |
</div>
|
17 |
"""
|
18 |
|
19 |
-
|
20 |
def render_plot(selected_labels, df, plot_placeholder):
|
21 |
if not selected_labels:
|
22 |
st.write("No data to display. Please select at least one subset.")
|
@@ -51,17 +49,7 @@ def render_plot(selected_labels, df, plot_placeholder):
|
|
51 |
|
52 |
plot_placeholder.bokeh_chart(p)
|
53 |
|
54 |
-
|
55 |
-
def render_plot_donut(selected_labels):
|
56 |
-
render_plot(selected_labels, df, plot_placeholder)
|
57 |
-
|
58 |
-
|
59 |
-
def render_plot_idefics2(selected_labels):
|
60 |
-
render_plot(selected_labels, df2, plot_placeholder2)
|
61 |
-
|
62 |
-
|
63 |
def config_style():
|
64 |
-
|
65 |
st.markdown(
|
66 |
"""
|
67 |
<style>
|
@@ -95,50 +83,67 @@ def config_style():
|
|
95 |
)
|
96 |
|
97 |
if __name__ == "__main__":
|
98 |
-
|
99 |
config_style()
|
100 |
|
101 |
-
# --- Primer gráfico: datos de
|
102 |
-
|
103 |
-
|
104 |
|
105 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
plot_placeholder = st.empty()
|
107 |
|
108 |
-
# Mostrar
|
109 |
-
|
110 |
|
111 |
-
# Desplegable
|
112 |
selected_labels = st.multiselect(
|
113 |
-
"",
|
114 |
options=unique_labels,
|
115 |
default=unique_labels
|
116 |
)
|
117 |
|
118 |
-
|
119 |
-
render_plot_donut(selected_labels)
|
120 |
|
121 |
-
# --- Segundo gráfico: datos de
|
122 |
st.markdown('<h2 class="sub-title">Idefics2</h2>', unsafe_allow_html=True)
|
123 |
|
124 |
-
|
125 |
-
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
-
|
129 |
plot_placeholder2 = st.empty()
|
130 |
|
|
|
131 |
|
132 |
-
# Mostrar inicialmente el segundo gráfico con todas las etiquetas
|
133 |
-
render_plot_idefics2(unique_labels2)
|
134 |
-
|
135 |
-
# Desplegable (multiselect) para el segundo gráfico
|
136 |
selected_labels2 = st.multiselect(
|
137 |
-
"",
|
138 |
options=unique_labels2,
|
139 |
default=unique_labels2,
|
140 |
key="idefics2"
|
141 |
)
|
142 |
|
143 |
-
|
144 |
-
render_plot_idefics2(selected_labels2)
|
|
|
4 |
from bokeh.models import ColumnDataSource
|
5 |
from bokeh.palettes import Category10
|
6 |
|
|
|
7 |
TOOLTIPS = """
|
8 |
<div>
|
9 |
<div>
|
|
|
15 |
</div>
|
16 |
"""
|
17 |
|
|
|
18 |
def render_plot(selected_labels, df, plot_placeholder):
|
19 |
if not selected_labels:
|
20 |
st.write("No data to display. Please select at least one subset.")
|
|
|
49 |
|
50 |
plot_placeholder.bokeh_chart(p)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
def config_style():
|
|
|
53 |
st.markdown(
|
54 |
"""
|
55 |
<style>
|
|
|
83 |
)
|
84 |
|
85 |
if __name__ == "__main__":
|
|
|
86 |
config_style()
|
87 |
|
88 |
+
# --- Primer gráfico: datos de Donut ---
|
89 |
+
df_donut_pca = pd.read_csv("data/data_donut_pca.csv")
|
90 |
+
df_donut_tsne = pd.read_csv("data/data_donut_tsne.csv")
|
91 |
|
92 |
+
# Desplegable para seleccionar visualización
|
93 |
+
donut_mode = st.selectbox(
|
94 |
+
"Seleccione visualización para Donut:",
|
95 |
+
options=["PCA", "t-SNE"]
|
96 |
+
)
|
97 |
+
|
98 |
+
# Escoger el DataFrame según la selección
|
99 |
+
if donut_mode == "PCA":
|
100 |
+
current_df_donut = df_donut_pca
|
101 |
+
else:
|
102 |
+
current_df_donut = df_donut_tsne
|
103 |
+
|
104 |
+
unique_labels = current_df_donut['label'].unique().tolist()
|
105 |
plot_placeholder = st.empty()
|
106 |
|
107 |
+
# Mostrar gráfico inicial con todas las etiquetas
|
108 |
+
render_plot(unique_labels, current_df_donut, plot_placeholder)
|
109 |
|
110 |
+
# Desplegable para filtrar etiquetas
|
111 |
selected_labels = st.multiselect(
|
112 |
+
"Seleccione subsets para visualizar (Donut):",
|
113 |
options=unique_labels,
|
114 |
default=unique_labels
|
115 |
)
|
116 |
|
117 |
+
render_plot(selected_labels, current_df_donut, plot_placeholder)
|
|
|
118 |
|
119 |
+
# --- Segundo gráfico: datos de Idefics2 ---
|
120 |
st.markdown('<h2 class="sub-title">Idefics2</h2>', unsafe_allow_html=True)
|
121 |
|
122 |
+
df_idefics2_pca = pd.read_csv("data/data_idefics2_pca.csv")
|
123 |
+
df_idefics2_tsne = pd.read_csv("data/data_idefics2_tsne.csv")
|
124 |
|
125 |
+
# Desplegable para seleccionar visualización para Idefics2
|
126 |
+
idefics2_mode = st.selectbox(
|
127 |
+
"Seleccione visualización para Idefics2:",
|
128 |
+
options=["PCA", "t-SNE"],
|
129 |
+
key="idefics2_mode"
|
130 |
+
)
|
131 |
+
|
132 |
+
if idefics2_mode == "PCA":
|
133 |
+
current_df_idefics2 = df_idefics2_pca
|
134 |
+
else:
|
135 |
+
current_df_idefics2 = df_idefics2_tsne
|
136 |
|
137 |
+
unique_labels2 = current_df_idefics2['label'].unique().tolist()
|
138 |
plot_placeholder2 = st.empty()
|
139 |
|
140 |
+
render_plot(unique_labels2, current_df_idefics2, plot_placeholder2)
|
141 |
|
|
|
|
|
|
|
|
|
142 |
selected_labels2 = st.multiselect(
|
143 |
+
"Seleccione subsets para visualizar (Idefics2):",
|
144 |
options=unique_labels2,
|
145 |
default=unique_labels2,
|
146 |
key="idefics2"
|
147 |
)
|
148 |
|
149 |
+
render_plot(selected_labels2, current_df_idefics2, plot_placeholder2)
|
|