Spaces:
Runtime error
Runtime error
Commit
·
7386027
1
Parent(s):
1333876
Update app.py
Browse files
app.py
CHANGED
@@ -106,10 +106,11 @@ def analizar_tweets(search_words, number_of_tweets):
|
|
106 |
df = df[df["Prediccion"] == 'Sexista']
|
107 |
df = df[df["Probabilidad"] > 0.5]
|
108 |
if df.empty:
|
109 |
-
st.text("No hay tweets a analizar")
|
|
|
110 |
else:
|
111 |
muestra = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
|
112 |
-
|
113 |
#resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
114 |
#colores=["#aae977","#EE3555"]
|
115 |
#fig, ax = plt.subplots(figsize=(2, 1), subplotpars=None)
|
@@ -122,13 +123,13 @@ def analizar_tweets(search_words, number_of_tweets):
|
|
122 |
#st.set_option('deprecation.showPyplotGlobalUse', False)
|
123 |
#st.pyplot()
|
124 |
except Exception as e:
|
125 |
-
st.text(f"La cuenta {search_words} no existe.")
|
126 |
-
|
127 |
else:
|
128 |
-
st.text("Ingrese los parametros correspondientes")
|
129 |
-
|
130 |
-
|
131 |
-
return
|
132 |
|
133 |
def tweets_localidad(buscar_localidad):
|
134 |
tabla = []
|
@@ -154,7 +155,8 @@ def tweets_localidad(buscar_localidad):
|
|
154 |
#muestra = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
|
155 |
|
156 |
if df.empty:
|
157 |
-
st.text("No se encontraron tweets sexistas dentro de la localidad")
|
|
|
158 |
else:
|
159 |
#tabla.append(muestra)
|
160 |
df.sort_values(by=['Prediccion', 'Probabilidad'], ascending=[False, False], inplace=True)
|
@@ -164,6 +166,7 @@ def tweets_localidad(buscar_localidad):
|
|
164 |
#df = df.sort_values(by='Probabilidad', ascending=False)
|
165 |
df['Probabilidad'] = df['Probabilidad'].apply(lambda x: round(x, 3))
|
166 |
muestra = st.table(df.reset_index(drop=True).head(10).style.applymap(color_survived, subset=['Prediccion']))
|
|
|
167 |
resultado=df.groupby('Prediccion')['Probabilidad'].mean()
|
168 |
colores=["#EE3555","#aae977"]
|
169 |
fig, ax = plt.subplots()
|
@@ -178,14 +181,16 @@ def tweets_localidad(buscar_localidad):
|
|
178 |
st.pyplot()
|
179 |
|
180 |
except AttributeError as e:
|
181 |
-
st.text("No existe ninguna localidad con ese nombre")
|
|
|
182 |
|
183 |
-
return
|
184 |
|
185 |
def analizar_frase(frase):
|
|
|
186 |
if frase == "":
|
187 |
-
|
188 |
-
st.text("Ingrese una frase")
|
189 |
else:
|
190 |
predictions = pipeline_nlp(frase)
|
191 |
# convierte las predicciones en una lista de diccionarios
|
|
|
106 |
df = df[df["Prediccion"] == 'Sexista']
|
107 |
df = df[df["Probabilidad"] > 0.5]
|
108 |
if df.empty:
|
109 |
+
muestra= st.text("No hay tweets a analizar")
|
110 |
+
tabla.append(muestra)
|
111 |
else:
|
112 |
muestra = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
|
113 |
+
tabla.append(muestra)
|
114 |
#resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
115 |
#colores=["#aae977","#EE3555"]
|
116 |
#fig, ax = plt.subplots(figsize=(2, 1), subplotpars=None)
|
|
|
123 |
#st.set_option('deprecation.showPyplotGlobalUse', False)
|
124 |
#st.pyplot()
|
125 |
except Exception as e:
|
126 |
+
muestra = st.text(f"La cuenta {search_words} no existe.")
|
127 |
+
tabla.append(muestra)
|
128 |
else:
|
129 |
+
muestra= st.text("Ingrese los parametros correspondientes")
|
130 |
+
tabla.append(muestra)
|
131 |
+
|
132 |
+
return tabla
|
133 |
|
134 |
def tweets_localidad(buscar_localidad):
|
135 |
tabla = []
|
|
|
155 |
#muestra = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
|
156 |
|
157 |
if df.empty:
|
158 |
+
muestra=st.text("No se encontraron tweets sexistas dentro de la localidad")
|
159 |
+
tabla.append(muestra)
|
160 |
else:
|
161 |
#tabla.append(muestra)
|
162 |
df.sort_values(by=['Prediccion', 'Probabilidad'], ascending=[False, False], inplace=True)
|
|
|
166 |
#df = df.sort_values(by='Probabilidad', ascending=False)
|
167 |
df['Probabilidad'] = df['Probabilidad'].apply(lambda x: round(x, 3))
|
168 |
muestra = st.table(df.reset_index(drop=True).head(10).style.applymap(color_survived, subset=['Prediccion']))
|
169 |
+
tabla.append(muestra)
|
170 |
resultado=df.groupby('Prediccion')['Probabilidad'].mean()
|
171 |
colores=["#EE3555","#aae977"]
|
172 |
fig, ax = plt.subplots()
|
|
|
181 |
st.pyplot()
|
182 |
|
183 |
except AttributeError as e:
|
184 |
+
muestra=st.text("No existe ninguna localidad con ese nombre")
|
185 |
+
tabla.append(muestra)
|
186 |
|
187 |
+
return tabla
|
188 |
|
189 |
def analizar_frase(frase):
|
190 |
+
|
191 |
if frase == "":
|
192 |
+
tabla = st.text("Ingrese una frase")
|
193 |
+
#st.text("Ingrese una frase")
|
194 |
else:
|
195 |
predictions = pipeline_nlp(frase)
|
196 |
# convierte las predicciones en una lista de diccionarios
|