Joshua1808 commited on
Commit
46ac277
·
1 Parent(s): b57da8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -150,16 +150,17 @@ def tweets_localidad(buscar_localidad):
150
  etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
151
  result.append(etiqueta)
152
  df = pd.DataFrame(result)
153
- df['Prediccion'] = np.where(df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
154
- df = df[df["Prediccion"] == 'Sexista']
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']))
158
 
159
  if df.empty:
160
  st.text("No se encontraron tweets sexistas dentro de la localidad")
161
  else:
162
- #tabla.append(muestra)
 
 
 
 
163
  muestra = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
164
  resultado=df.groupby('Prediccion')['Probabilidad'].sum()
165
  colores=["#aae977","#EE3555"]
@@ -174,7 +175,7 @@ def tweets_localidad(buscar_localidad):
174
  st.set_option('deprecation.showPyplotGlobalUse', False)
175
  st.pyplot()
176
 
177
- except Exception as e:
178
  st.text("No existe ninguna localidad con ese nombre")
179
 
180
  return muestra
 
150
  etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
151
  result.append(etiqueta)
152
  df = pd.DataFrame(result)
153
+
 
 
 
154
  #muestra = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
155
 
156
  if df.empty:
157
  st.text("No se encontraron tweets sexistas dentro de la localidad")
158
  else:
159
+ #tabla.append(muestra)
160
+ df['Prediccion'] = np.where(df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
161
+ df = df[df["Prediccion"] == 'Sexista']
162
+ df = df[df["Probabilidad"] > 0.5]
163
+ df = df.sort_values(by='Probabilidad', ascending=False)
164
  muestra = st.table(df.reset_index(drop=True).head(5).style.applymap(color_survived, subset=['Prediccion']))
165
  resultado=df.groupby('Prediccion')['Probabilidad'].sum()
166
  colores=["#aae977","#EE3555"]
 
175
  st.set_option('deprecation.showPyplotGlobalUse', False)
176
  st.pyplot()
177
 
178
+ except AttributeError as e:
179
  st.text("No existe ninguna localidad con ese nombre")
180
 
181
  return muestra