Spaces:
Runtime error
Runtime error
Commit
·
8a0bbec
1
Parent(s):
b9decf4
Update app.py
Browse files
app.py
CHANGED
@@ -94,23 +94,28 @@ def analizar_tweets(search_words, number_of_tweets):
|
|
94 |
prediction = pipeline_nlp(datos)
|
95 |
for predic in prediction:
|
96 |
etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
97 |
-
result.append(etiqueta)
|
|
|
98 |
df = pd.DataFrame(result)
|
99 |
-
df
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
114 |
else:
|
115 |
tabla = st.text("Ingrese la cantidad de tweets")
|
116 |
|
|
|
94 |
prediction = pipeline_nlp(datos)
|
95 |
for predic in prediction:
|
96 |
etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
97 |
+
result.append(etiqueta)
|
98 |
+
|
99 |
df = pd.DataFrame(result)
|
100 |
+
if df.empty:
|
101 |
+
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
102 |
+
df = df[df["Prediccion"] == 'Sexista']
|
103 |
+
df = df[df["Probabilidad"] > 0.5]
|
104 |
+
tabla = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
|
105 |
+
resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
106 |
+
colores=["#aae977","#EE3555"]
|
107 |
+
fig, ax = plt.subplots(figsize=(1, 1), subplotpars=None)
|
108 |
+
plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
|
109 |
+
ax.set_title("Porcentajes por Categorias", fontsize=1, fontweight="bold")
|
110 |
+
plt.rcParams.update({'font.size':1, 'font.weight':'bold'})
|
111 |
+
ax.legend()
|
112 |
+
# Muestra el gráfico
|
113 |
+
plt.show()
|
114 |
+
st.set_option('deprecation.showPyplotGlobalUse', False)
|
115 |
+
st.pyplot()
|
116 |
+
else:
|
117 |
+
st.text("No hay tweets a analizar")
|
118 |
+
|
119 |
else:
|
120 |
tabla = st.text("Ingrese la cantidad de tweets")
|
121 |
|