Spaces:
Runtime error
Runtime error
Commit
·
2e8cc31
1
Parent(s):
a4b45a1
Update app.py
Browse files
app.py
CHANGED
@@ -101,32 +101,31 @@ def analizar_tweets(search_words, number_of_tweets):
|
|
101 |
etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
102 |
result.append(etiqueta)
|
103 |
df = pd.DataFrame(result)
|
|
|
|
|
|
|
|
|
104 |
if df.empty:
|
105 |
-
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
106 |
-
#df = df[df["Prediccion"] == 'Sexista']
|
107 |
-
df = df[df["Probabilidad"] > 0.5]
|
108 |
-
muestra = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
|
109 |
tabla.append(muestra)
|
110 |
-
resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
111 |
-
colores=["#aae977","#EE3555"]
|
112 |
-
fig, ax = plt.subplots(figsize=(2, 1), subplotpars=None)
|
113 |
-
plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
|
114 |
-
ax.set_title("Porcentajes por Categorias", fontsize=
|
115 |
-
plt.rcParams.update({'font.size':
|
116 |
-
ax.legend()
|
117 |
# Muestra el gráfico
|
118 |
-
plt.show()
|
119 |
-
st.set_option('deprecation.showPyplotGlobalUse', False)
|
120 |
-
st.pyplot()
|
121 |
else:
|
122 |
-
|
123 |
-
tabla.append(muestra)
|
124 |
except Exception as e:
|
125 |
st.text(f"La cuenta {search_words} no existe.")
|
126 |
|
127 |
else:
|
128 |
-
|
129 |
-
|
130 |
|
131 |
return tabla
|
132 |
|
@@ -151,7 +150,7 @@ def tweets_localidad(buscar_localidad):
|
|
151 |
result.append(etiqueta)
|
152 |
df = pd.DataFrame(result)
|
153 |
df['Prediccion'] = np.where(df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
154 |
-
|
155 |
df = df[df["Probabilidad"] > 0.5]
|
156 |
df = df.sort_values(by='Probabilidad', ascending=False)
|
157 |
muestra = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
|
@@ -165,8 +164,8 @@ def tweets_localidad(buscar_localidad):
|
|
165 |
fig, ax = plt.subplots()
|
166 |
fig.set_size_inches(2, 1)
|
167 |
plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
|
168 |
-
ax.set_title("Porcentajes por Categorias", fontsize=
|
169 |
-
plt.rcParams.update({'font.size':
|
170 |
ax.legend()
|
171 |
# Muestra el gráfico
|
172 |
plt.show()
|
|
|
101 |
etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
102 |
result.append(etiqueta)
|
103 |
df = pd.DataFrame(result)
|
104 |
+
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
105 |
+
df = df[df["Prediccion"] == 'Sexista']
|
106 |
+
df = df[df["Probabilidad"] > 0.5]
|
107 |
+
muestra = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
|
108 |
if df.empty:
|
|
|
|
|
|
|
|
|
109 |
tabla.append(muestra)
|
110 |
+
#resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
111 |
+
#colores=["#aae977","#EE3555"]
|
112 |
+
#fig, ax = plt.subplots(figsize=(2, 1), subplotpars=None)
|
113 |
+
#plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
|
114 |
+
#ax.set_title("Porcentajes por Categorias", fontsize=2, fontweight="bold")
|
115 |
+
#plt.rcParams.update({'font.size':2, 'font.weight':'bold'})
|
116 |
+
#ax.legend()
|
117 |
# Muestra el gráfico
|
118 |
+
#plt.show()
|
119 |
+
#st.set_option('deprecation.showPyplotGlobalUse', False)
|
120 |
+
#st.pyplot()
|
121 |
else:
|
122 |
+
st.text("No hay tweets a analizar")
|
|
|
123 |
except Exception as e:
|
124 |
st.text(f"La cuenta {search_words} no existe.")
|
125 |
|
126 |
else:
|
127 |
+
st.text("Ingrese los parametros correspondientes")
|
128 |
+
|
129 |
|
130 |
return tabla
|
131 |
|
|
|
150 |
result.append(etiqueta)
|
151 |
df = pd.DataFrame(result)
|
152 |
df['Prediccion'] = np.where(df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
153 |
+
df = df[df["Prediccion"] == 'Sexista']
|
154 |
df = df[df["Probabilidad"] > 0.5]
|
155 |
df = df.sort_values(by='Probabilidad', ascending=False)
|
156 |
muestra = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
|
|
|
164 |
fig, ax = plt.subplots()
|
165 |
fig.set_size_inches(2, 1)
|
166 |
plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
|
167 |
+
ax.set_title("Porcentajes por Categorias", fontsize=2, fontweight="bold")
|
168 |
+
plt.rcParams.update({'font.size':2, 'font.weight':'bold'})
|
169 |
ax.legend()
|
170 |
# Muestra el gráfico
|
171 |
plt.show()
|