Spaces:
Running
Running
Commit
·
6071181
1
Parent(s):
20a443e
Revert "Choose t-sne or PCA"
Browse filesThis reverts commit 3f42d492159c6c3f3f8bd5058e241b884860c22d.
app.py
CHANGED
@@ -4,6 +4,7 @@ from bokeh.plotting import figure
|
|
4 |
from bokeh.models import ColumnDataSource
|
5 |
from bokeh.palettes import Category10
|
6 |
|
|
|
7 |
TOOLTIPS = """
|
8 |
<div>
|
9 |
<div>
|
@@ -15,6 +16,7 @@ TOOLTIPS = """
|
|
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,7 +51,17 @@ def render_plot(selected_labels, df, plot_placeholder):
|
|
49 |
|
50 |
plot_placeholder.bokeh_chart(p)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
def config_style():
|
|
|
53 |
st.markdown(
|
54 |
"""
|
55 |
<style>
|
@@ -83,67 +95,50 @@ def config_style():
|
|
83 |
)
|
84 |
|
85 |
if __name__ == "__main__":
|
86 |
-
config_style()
|
87 |
|
88 |
-
|
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 |
-
#
|
93 |
-
|
94 |
-
|
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 |
-
|
105 |
plot_placeholder = st.empty()
|
106 |
|
107 |
-
# Mostrar gráfico
|
108 |
-
|
109 |
|
110 |
-
# Desplegable para
|
111 |
selected_labels = st.multiselect(
|
112 |
-
"
|
113 |
options=unique_labels,
|
114 |
default=unique_labels
|
115 |
)
|
116 |
|
117 |
-
|
|
|
118 |
|
119 |
-
# --- Segundo gráfico: datos de
|
120 |
st.markdown('<h2 class="sub-title">Idefics2</h2>', unsafe_allow_html=True)
|
121 |
|
122 |
-
|
123 |
-
|
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 |
-
|
138 |
plot_placeholder2 = st.empty()
|
139 |
|
140 |
-
render_plot(unique_labels2, current_df_idefics2, plot_placeholder2)
|
141 |
|
|
|
|
|
|
|
|
|
142 |
selected_labels2 = st.multiselect(
|
143 |
-
"
|
144 |
options=unique_labels2,
|
145 |
default=unique_labels2,
|
146 |
key="idefics2"
|
147 |
)
|
148 |
|
149 |
-
|
|
|
|
4 |
from bokeh.models import ColumnDataSource
|
5 |
from bokeh.palettes import Category10
|
6 |
|
7 |
+
|
8 |
TOOLTIPS = """
|
9 |
<div>
|
10 |
<div>
|
|
|
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 |
|
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 |
)
|
96 |
|
97 |
if __name__ == "__main__":
|
|
|
98 |
|
99 |
+
config_style()
|
|
|
|
|
100 |
|
101 |
+
# --- Primer gráfico: datos de data.csv ---
|
102 |
+
df = pd.read_csv("data/data_donut_pca.csv")
|
103 |
+
unique_labels = df['label'].unique().tolist()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
+
# Contenedor para el primer gráfico
|
106 |
plot_placeholder = st.empty()
|
107 |
|
108 |
+
# Mostrar inicialmente el primer gráfico con todas las etiquetas
|
109 |
+
render_plot_donut(unique_labels)
|
110 |
|
111 |
+
# Desplegable (multiselect) para el primer gráfico
|
112 |
selected_labels = st.multiselect(
|
113 |
+
"",
|
114 |
options=unique_labels,
|
115 |
default=unique_labels
|
116 |
)
|
117 |
|
118 |
+
# Actualizar gráfico al cambiar la selección
|
119 |
+
render_plot_donut(selected_labels)
|
120 |
|
121 |
+
# --- Segundo gráfico: datos de data_idefics2.csv ---
|
122 |
st.markdown('<h2 class="sub-title">Idefics2</h2>', unsafe_allow_html=True)
|
123 |
|
124 |
+
df2 = pd.read_csv("data/data_donut_tnse.csv")
|
125 |
+
unique_labels2 = df2['label'].unique().tolist()
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
+
# Contenedor para el segundo gráfico
|
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 |
+
# Actualizar el gráfico del segundo conjunto de datos al cambiar la selección
|
144 |
+
render_plot_idefics2(selected_labels2)
|