Spaces:
Runtime error
Runtime error
Commit
·
89d7f96
1
Parent(s):
f9ed481
Update app.py
Browse files
app.py
CHANGED
@@ -112,7 +112,7 @@ def analizar_tweets(search_words, number_of_tweets):
|
|
112 |
st.set_option('deprecation.showPyplotGlobalUse', False)
|
113 |
st.pyplot()
|
114 |
else:
|
115 |
-
tabla = st.text("Ingrese
|
116 |
|
117 |
return tabla
|
118 |
|
@@ -149,10 +149,10 @@ def tweets_localidad(buscar_localidad):
|
|
149 |
resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
150 |
colores=["#aae977","#EE3555"]
|
151 |
fig, ax = plt.subplots()
|
152 |
-
fig.set_size_inches(
|
153 |
plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
|
154 |
-
ax.set_title("Porcentajes por Categorias", fontsize=
|
155 |
-
plt.rcParams.update({'font.size':
|
156 |
ax.legend()
|
157 |
# Muestra el gráfico
|
158 |
plt.show()
|
@@ -165,15 +165,18 @@ def tweets_localidad(buscar_localidad):
|
|
165 |
return tabla
|
166 |
|
167 |
def analizar_frase(frase):
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
177 |
return tabla
|
178 |
|
179 |
def run():
|
|
|
112 |
st.set_option('deprecation.showPyplotGlobalUse', False)
|
113 |
st.pyplot()
|
114 |
else:
|
115 |
+
tabla = st.text("Ingrese la cantidad de tweets")
|
116 |
|
117 |
return tabla
|
118 |
|
|
|
149 |
resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
150 |
colores=["#aae977","#EE3555"]
|
151 |
fig, ax = plt.subplots()
|
152 |
+
fig.set_size_inches(0.5, 1)
|
153 |
plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
|
154 |
+
ax.set_title("Porcentajes por Categorias", fontsize=4, fontweight="bold")
|
155 |
+
plt.rcParams.update({'font.size':3, 'font.weight':'bold'})
|
156 |
ax.legend()
|
157 |
# Muestra el gráfico
|
158 |
plt.show()
|
|
|
165 |
return tabla
|
166 |
|
167 |
def analizar_frase(frase):
|
168 |
+
if frase == "":
|
169 |
+
predictions = pipeline_nlp(frase)
|
170 |
+
# convierte las predicciones en una lista de diccionarios
|
171 |
+
data = [{'Texto': frase, 'Prediccion': prediction['label'], 'Probabilidad': prediction['score']} for prediction in predictions]
|
172 |
+
# crea un DataFrame a partir de la lista de diccionarios
|
173 |
+
df = pd.DataFrame(data)
|
174 |
+
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
175 |
+
# muestra el DataFrame
|
176 |
+
tabla = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
|
177 |
+
else:
|
178 |
+
tabla = st.text("Ingrese una frase")
|
179 |
+
|
180 |
return tabla
|
181 |
|
182 |
def run():
|