Joshua1808 commited on
Commit
afeaaa3
·
1 Parent(s): 8c9c4f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -157,27 +157,32 @@ def tweets_localidad(buscar_localidad):
157
  result.append(etiqueta)
158
  df = pd.DataFrame(result)
159
  df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
 
160
  df=df[df["Prediccion"] == 'Sexista']
161
  tabla = st.table(df.reset_index(drop=True).head(50).style.applymap(color_survived, subset=['Prediccion']))
162
-
163
  df_sexista = df[df['Prediccion']=="Sexista"]
164
- df_no_sexista = df[df['Probabilidad'] > 0]
165
  sexista = len(df_sexista)
166
  no_sexista = len(df_no_sexista)
167
 
168
- # Crear un gráfico de barras
169
- labels = ['Sexista ', ' No sexista']
170
- counts = [sexista, no_sexista]
171
- plt.bar(labels, counts)
172
- plt.xlabel('Categoría')
173
- plt.ylabel('Cantidad de tweets')
174
- plt.title('Cantidad de tweets sexistas y no sexistas')
175
- plt.figure(figsize=(10,6))
176
- plt.show()
177
- st.set_option('deprecation.showPyplotGlobalUse', False)
178
-
 
 
 
 
179
  st.pyplot()
180
-
181
 
182
  except AttributeError:
183
  st.text("No existe ninguna localidad con ese nombre")
 
157
  result.append(etiqueta)
158
  df = pd.DataFrame(result)
159
  df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
160
+ df['Probabilidad'] = df['Probabilidad'] * 100
161
  df=df[df["Prediccion"] == 'Sexista']
162
  tabla = st.table(df.reset_index(drop=True).head(50).style.applymap(color_survived, subset=['Prediccion']))
163
+
164
  df_sexista = df[df['Prediccion']=="Sexista"]
165
+ df_no_sexista = df[df['Prediccion']=="No Sexista"]
166
  sexista = len(df_sexista)
167
  no_sexista = len(df_no_sexista)
168
 
169
+ labels = ['Sexista', 'No Sexista']
170
+ sizes = [sexista, no_sexista]
171
+ colors = ['#ff9999','#66b3ff']
172
+
173
+ fig1, ax1 = plt.subplots()
174
+ ax1.pie(sizes, colors = colors, labels=labels, startangle=90, frame = True, counterclock = False, autopct='%1.1f%%')
175
+
176
+ #draw circle
177
+ centre_circle = plt.Circle((0,0),0.70,fc='white')
178
+ fig = plt.gcf()
179
+ fig.gca().add_artist(centre_circle)
180
+
181
+ # Equal aspect ratio ensures that pie is drawn as a circle
182
+ ax1.axis('equal')
183
+ plt.tight_layout()
184
  st.pyplot()
185
+ st.set_option('deprecation.showPyplotGlobalUse', False)
186
 
187
  except AttributeError:
188
  st.text("No existe ninguna localidad con ese nombre")