Spaces:
Runtime error
Runtime error
Commit
·
19aeb3f
1
Parent(s):
bb0de7f
Update app.py
Browse files
app.py
CHANGED
@@ -135,25 +135,24 @@ def tweets_localidad(buscar_localidad):
|
|
135 |
result.append(etiqueta)
|
136 |
df = pd.DataFrame(result)
|
137 |
if df.empty:
|
138 |
-
|
139 |
-
tabla.append(muestra)
|
140 |
else:
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
|
158 |
except AttributeError:
|
159 |
st.text("No existe ninguna localidad con ese nombre")
|
@@ -176,9 +175,9 @@ def run():
|
|
176 |
with st.form("my_form"):
|
177 |
col,buff1, buff2 = st.columns([2,2,1])
|
178 |
st.write("Escoja una Opción")
|
179 |
-
search_words = col.text_input("Introduzca
|
180 |
number_of_tweets = col.number_input('Introduzca número de tweets a analizar. Máximo 50', 0,50,0)
|
181 |
-
termino=st.checkbox('
|
182 |
usuario=st.checkbox('Usuario')
|
183 |
localidad=st.checkbox('Localidad')
|
184 |
submit_button = col.form_submit_button(label='Analizar')
|
|
|
135 |
result.append(etiqueta)
|
136 |
df = pd.DataFrame(result)
|
137 |
if df.empty:
|
138 |
+
st.text("No se encontraron tweets sexistas dentro de la localidad")
|
|
|
139 |
else:
|
140 |
+
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
141 |
+
df = df[df["Prediccion"] == 'Sexista']
|
142 |
+
df = df[df["Probabilidad"] > 0.80]
|
143 |
+
muestra = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
|
144 |
+
tabla.append(muestra)
|
145 |
+
resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
146 |
+
colores=["#aae977","#EE3555"]
|
147 |
+
fig, ax = plt.subplots(figsize=(4, 4), subplotpars=None)
|
148 |
+
plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
|
149 |
+
ax.set_title("Porcentajes por Categorias", fontsize=8, fontweight="bold")
|
150 |
+
plt.rcParams.update({'font.size':8, 'font.weight':'bold'})
|
151 |
+
ax.legend()
|
152 |
+
# Muestra el gráfico
|
153 |
+
plt.show()
|
154 |
+
st.set_option('deprecation.showPyplotGlobalUse', False)
|
155 |
+
st.pyplot()
|
156 |
|
157 |
except AttributeError:
|
158 |
st.text("No existe ninguna localidad con ese nombre")
|
|
|
175 |
with st.form("my_form"):
|
176 |
col,buff1, buff2 = st.columns([2,2,1])
|
177 |
st.write("Escoja una Opción")
|
178 |
+
search_words = col.text_input("Introduzca la frase, el usuario o localidad para analizar y pulse el check correspondiente")
|
179 |
number_of_tweets = col.number_input('Introduzca número de tweets a analizar. Máximo 50', 0,50,0)
|
180 |
+
termino=st.checkbox('Frase')
|
181 |
usuario=st.checkbox('Usuario')
|
182 |
localidad=st.checkbox('Localidad')
|
183 |
submit_button = col.form_submit_button(label='Analizar')
|