Joshua1808 commited on
Commit
b33ca04
·
1 Parent(s): da8d3c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -23
app.py CHANGED
@@ -149,31 +149,19 @@ def tweets_localidad(buscar_localidad):
149
  #df=df[df["Prediccion"] == 'Sexista']
150
  muestra = st.table(df.reset_index(drop=True).head(50).style.applymap(color_survived, subset=['Prediccion']))
151
  tabla.append(muestra)
152
- df_sexista = df[df['Prediccion']=="Sexista"]
153
- df_no_sexista = df[df['Prediccion']=="No Sexista"]
154
- sexista = len(df_sexista)
155
- no_sexista = len(df_no_sexista)
156
-
157
- labels = ['Sexista', 'No Sexista']
158
- sizes = [sexista, no_sexista]
159
- colors = ['#ff9999','#66b3ff']
160
-
161
- fig1, ax1 = plt.subplots()
162
- ax1.pie(sizes, colors = colors, labels=labels, startangle=90, frame = True, counterclock = False, autopct='%1.1f%%')
163
-
164
- #draw circle
165
- centre_circle = plt.Circle((0,0),0.70,fc='white')
166
- fig = plt.gcf()
167
- fig.gca().add_artist(centre_circle)
168
- fig.set_size_inches(4, 2)
169
-
170
 
171
- # Equal aspect ratio ensures that pie is drawn as a circle
172
- ax1.axis('equal')
173
- plt.tight_layout()
174
- st.pyplot(fig)
175
- st.set_option('deprecation.showPyplotGlobalUse', False)
176
 
 
 
 
 
 
 
 
177
  except AttributeError:
178
  st.text("No existe ninguna localidad con ese nombre")
179
 
 
149
  #df=df[df["Prediccion"] == 'Sexista']
150
  muestra = st.table(df.reset_index(drop=True).head(50).style.applymap(color_survived, subset=['Prediccion']))
151
  tabla.append(muestra)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
+ resultado=df.groupby('Prediccion')['Probabilidad'].sum()
154
+ colores=["#aae977","#EE3555"]
155
+ fig, ax = plt.subplots()
156
+ plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
 
157
 
158
+ #plt.title("Sumatoria de probabilidades por etiqueta")
159
+ ax.set_title("Porcentajes por Categorias", fontsize=12, fontweight="bold")
160
+ plt.rcParams.update({'font.size':10, 'font.weight':'bold'})
161
+ ax.legend()
162
+ # Muestra el gráfico
163
+ st.set_option('deprecation.showPyplotGlobalUse', False)
164
+ plt.show()
165
  except AttributeError:
166
  st.text("No existe ninguna localidad con ese nombre")
167