Joshua1808 commited on
Commit
70da8b4
·
1 Parent(s): 7386027

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -102,13 +102,16 @@ def analizar_tweets(search_words, number_of_tweets):
102
  etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
103
  result.append(etiqueta)
104
  df = pd.DataFrame(result)
105
- df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
106
- df = df[df["Prediccion"] == 'Sexista']
107
- df = df[df["Probabilidad"] > 0.5]
108
  if df.empty:
109
  muestra= st.text("No hay tweets a analizar")
110
  tabla.append(muestra)
111
  else:
 
 
 
112
  muestra = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
113
  tabla.append(muestra)
114
  #resultado=df.groupby('Prediccion')['Probabilidad'].sum()
 
102
  etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
103
  result.append(etiqueta)
104
  df = pd.DataFrame(result)
105
+ #df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
106
+ #df = df[df["Prediccion"] == 'Sexista']
107
+ #df = df[df["Probabilidad"] > 0.5]
108
  if df.empty:
109
  muestra= st.text("No hay tweets a analizar")
110
  tabla.append(muestra)
111
  else:
112
+ df.sort_values(by=['Prediccion', 'Probabilidad'], ascending=[False, False], inplace=True)
113
+ df['Prediccion'] = np.where(df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
114
+ df['Probabilidad'] = df['Probabilidad'].apply(lambda x: round(x, 3))
115
  muestra = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
116
  tabla.append(muestra)
117
  #resultado=df.groupby('Prediccion')['Probabilidad'].sum()