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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -16
app.py CHANGED
@@ -94,23 +94,28 @@ 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
  df = pd.DataFrame(result)
99
- df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
100
- df = df[df["Prediccion"] == 'Sexista']
101
- df = df[df["Probabilidad"] > 0.5]
102
- tabla = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
103
- resultado=df.groupby('Prediccion')['Probabilidad'].sum()
104
- colores=["#aae977","#EE3555"]
105
- fig, ax = plt.subplots(figsize=(1, 1), subplotpars=None)
106
- plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
107
- ax.set_title("Porcentajes por Categorias", fontsize=1, fontweight="bold")
108
- plt.rcParams.update({'font.size':1, 'font.weight':'bold'})
109
- ax.legend()
110
- # Muestra el gráfico
111
- plt.show()
112
- st.set_option('deprecation.showPyplotGlobalUse', False)
113
- st.pyplot()
 
 
 
 
114
  else:
115
  tabla = st.text("Ingrese la cantidad de tweets")
116
 
 
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