Joshua1808 commited on
Commit
fe0b968
·
1 Parent(s): dad8f09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -25
app.py CHANGED
@@ -157,34 +157,35 @@ def tweets_localidad(buscar_localidad):
157
  prediction = pipeline_nlp(text)
158
  for predic in prediction:
159
  etiqueta = {'Tweets': text,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
160
- result.append(etiqueta)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  except AttributeError:
162
  st.text("No existe ninguna localidad con ese nombre")
163
 
164
- df = pd.DataFrame(result)
165
- df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
166
- #tabla = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
167
- #df['Tweets'] = df['Tweets'].str.replace('RT|@', '')
168
- df=df[df["Prediccion"] == 'Sexista']
169
- tabla = st.table(df.reset_index(drop=True).head(50).style.applymap(color_survived, subset=['Prediccion']))
170
-
171
- df_sexista = df[df['Prediccion']=="Sexista"]
172
- df_no_sexista = df[df['Probabilidad'] > 0]
173
- sexista = len(df_sexista)
174
- no_sexista = len(df_no_sexista)
175
-
176
- # Crear un gráfico de barras
177
- labels = ['Sexista ', ' No sexista']
178
- counts = [sexista, no_sexista]
179
- plt.bar(labels, counts)
180
- plt.xlabel('Categoría')
181
- plt.ylabel('Cantidad de tweets')
182
- plt.title('Cantidad de tweets sexistas y no sexistas')
183
- plt.figure(figsize=(10,6))
184
- plt.show()
185
- st.pyplot()
186
-
187
- st.set_option('deprecation.showPyplotGlobalUse', False)
188
 
189
  return tabla
190
 
 
157
  prediction = pipeline_nlp(text)
158
  for predic in prediction:
159
  etiqueta = {'Tweets': text,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
160
+ result.append(etiqueta)
161
+ df = pd.DataFrame(result)
162
+ df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
163
+ #tabla = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
164
+ #df['Tweets'] = df['Tweets'].str.replace('RT|@', '')
165
+ df=df[df["Prediccion"] == 'Sexista']
166
+ tabla = st.table(df.reset_index(drop=True).head(50).style.applymap(color_survived, subset=['Prediccion']))
167
+
168
+ df_sexista = df[df['Prediccion']=="Sexista"]
169
+ df_no_sexista = df[df['Probabilidad'] > 0]
170
+ sexista = len(df_sexista)
171
+ no_sexista = len(df_no_sexista)
172
+
173
+ # Crear un gráfico de barras
174
+ labels = ['Sexista ', ' No sexista']
175
+ counts = [sexista, no_sexista]
176
+ plt.bar(labels, counts)
177
+ plt.xlabel('Categoría')
178
+ plt.ylabel('Cantidad de tweets')
179
+ plt.title('Cantidad de tweets sexistas y no sexistas')
180
+ plt.figure(figsize=(10,6))
181
+ plt.show()
182
+ st.pyplot()
183
+
184
+ st.set_option('deprecation.showPyplotGlobalUse', False)
185
  except AttributeError:
186
  st.text("No existe ninguna localidad con ese nombre")
187
 
188
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
  return tabla
191