Joshua1808 commited on
Commit
d5291cb
·
1 Parent(s): b5a9d85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -133,7 +133,9 @@ def tweets_localidad(buscar_localidad):
133
  text_list = text[0].tolist()
134
  result = []
135
  for text in text_list:
136
- if (text.startswith('RT')):
 
 
137
  continue
138
  else:
139
  prediction = pipeline_nlp(text)
@@ -142,17 +144,18 @@ def tweets_localidad(buscar_localidad):
142
  result.append(etiqueta)
143
  df = pd.DataFrame(result)
144
  df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
145
- #df['Tweets'] = df['Tweets'].str.replace('RT|@', '')
146
  #df['Probabilidad'] = df['Probabilidad'].apply(lambda x: '{:.2f}%'.format(x))
147
  #df.sort_values(by='Probabilidad', ascending=False, inplace=True)
148
  #df = df.sort_values(by=['Probabilidad', 'Prediccion'], ascending=[False, False])
149
- #df=df[df["Prediccion"] == 'Sexista']
 
150
  muestra = st.table(df.reset_index(drop=True).head(30).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(figsize=(8, 8), subplotpars=None)
156
  plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
157
  ax.set_title("Porcentajes por Categorias", fontsize=8, fontweight="bold")
158
  plt.rcParams.update({'font.size':8, 'font.weight':'bold'})
 
133
  text_list = text[0].tolist()
134
  result = []
135
  for text in text_list:
136
+ if (text.startswith('RT') ):
137
+ continue
138
+ elif not text.strip():
139
  continue
140
  else:
141
  prediction = pipeline_nlp(text)
 
144
  result.append(etiqueta)
145
  df = pd.DataFrame(result)
146
  df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
147
+ df['Tweets'] = df['Tweets'].str.replace('RT|@', '')
148
  #df['Probabilidad'] = df['Probabilidad'].apply(lambda x: '{:.2f}%'.format(x))
149
  #df.sort_values(by='Probabilidad', ascending=False, inplace=True)
150
  #df = df.sort_values(by=['Probabilidad', 'Prediccion'], ascending=[False, False])
151
+ df=df[df["Prediccion"] == 'Sexista']
152
+ df=df[df["Probabilidad"] > 0.8]
153
  muestra = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
154
  tabla.append(muestra)
155
 
156
  resultado=df.groupby('Prediccion')['Probabilidad'].sum()
157
  colores=["#aae977","#EE3555"]
158
+ fig, ax = plt.subplots(figsize=(4, 4), subplotpars=None)
159
  plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
160
  ax.set_title("Porcentajes por Categorias", fontsize=8, fontweight="bold")
161
  plt.rcParams.update({'font.size':8, 'font.weight':'bold'})