Joshua1808 commited on
Commit
25d1d99
·
1 Parent(s): 8a0bbec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -19
app.py CHANGED
@@ -84,6 +84,7 @@ def analizar_tweets(search_words, number_of_tweets):
84
  if(number_of_tweets > 0):
85
  tweets = api.user_timeline(screen_name = search_words,tweet_mode="extended", count= number_of_tweets)
86
  result = []
 
87
  for tweet in tweets:
88
  if (tweet.full_text.startswith('RT')):
89
  continue
@@ -94,30 +95,30 @@ def analizar_tweets(search_words, number_of_tweets):
94
  prediction = pipeline_nlp(datos)
95
  for predic in prediction:
96
  etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
97
- result.append(etiqueta)
98
-
99
  df = pd.DataFrame(result)
100
  if df.empty:
101
- df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
102
- df = df[df["Prediccion"] == 'Sexista']
103
- df = df[df["Probabilidad"] > 0.5]
104
- tabla = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
105
- resultado=df.groupby('Prediccion')['Probabilidad'].sum()
106
- colores=["#aae977","#EE3555"]
107
- fig, ax = plt.subplots(figsize=(1, 1), subplotpars=None)
108
- plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
109
- ax.set_title("Porcentajes por Categorias", fontsize=1, fontweight="bold")
110
- plt.rcParams.update({'font.size':1, 'font.weight':'bold'})
111
- ax.legend()
112
- # Muestra el gráfico
113
- plt.show()
114
- st.set_option('deprecation.showPyplotGlobalUse', False)
115
- st.pyplot()
 
116
  else:
117
- st.text("No hay tweets a analizar")
118
 
119
  else:
120
- tabla = st.text("Ingrese la cantidad de tweets")
121
 
122
  return tabla
123
 
 
84
  if(number_of_tweets > 0):
85
  tweets = api.user_timeline(screen_name = search_words,tweet_mode="extended", count= number_of_tweets)
86
  result = []
87
+ tabla = []
88
  for tweet in tweets:
89
  if (tweet.full_text.startswith('RT')):
90
  continue
 
95
  prediction = pipeline_nlp(datos)
96
  for predic in prediction:
97
  etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
98
+ result.append(etiqueta)
 
99
  df = pd.DataFrame(result)
100
  if df.empty:
101
+ df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
102
+ df = df[df["Prediccion"] == 'Sexista']
103
+ df = df[df["Probabilidad"] > 0.5]
104
+ muestra = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
105
+ tabla.append(muestra)
106
+ resultado=df.groupby('Prediccion')['Probabilidad'].sum()
107
+ colores=["#aae977","#EE3555"]
108
+ fig, ax = plt.subplots(figsize=(1, 1), subplotpars=None)
109
+ plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
110
+ ax.set_title("Porcentajes por Categorias", fontsize=1, fontweight="bold")
111
+ plt.rcParams.update({'font.size':1, 'font.weight':'bold'})
112
+ ax.legend()
113
+ # Muestra el gráfico
114
+ plt.show()
115
+ st.set_option('deprecation.showPyplotGlobalUse', False)
116
+ st.pyplot()
117
  else:
118
+ st.text("No hay tweets a analizar")
119
 
120
  else:
121
+ st.text("Ingrese la cantidad de tweets")
122
 
123
  return tabla
124