robertou2 commited on
Commit
99a9eeb
1 Parent(s): bdcf72a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -54,6 +54,10 @@ def preprocess(text):
54
  text=re.sub(r"\)","",text)
55
  text=" ".join(text.split())
56
  return text
 
 
 
 
57
 
58
  st.set_page_config(layout="wide")
59
  st.markdown('<style>body{background-color: Blue;}</style>',unsafe_allow_html=True)
@@ -62,7 +66,7 @@ colT1,colT2 = st.columns([2,8])
62
  with colT2:
63
  #st.title('Analisis de comentarios sexistas en Twitter')
64
  st.markdown(""" <style> .font {
65
- font-size:40px ; font-family: 'Cooper Black'; color: #FF9633;}
66
  </style> """, unsafe_allow_html=True)
67
  st.markdown('<p class="font">Análisis de comentarios sexistas en Twitter</p>', unsafe_allow_html=True)
68
 
@@ -151,6 +155,8 @@ def run():
151
  flat_predictions = np.argmax(flat_predictions, axis=1).flatten()#p = [i for i in classifier(tweet_list)]
152
  df = pd.DataFrame(list(zip(tweet_list, flat_predictions)),columns =['Últimos '+ str(number_of_tweets)+' Tweets'+' de '+search_words, 'Sexista'])
153
  df['Sexista']= np.where(df['Sexista']== 0, 'No Sexista', 'Sexista')
154
- st.table(df)
 
 
155
  #st.write(df)
156
  run()
 
54
  text=re.sub(r"\)","",text)
55
  text=" ".join(text.split())
56
  return text
57
+
58
+ def highlight_survived(s):
59
+ return ['background-color: red']*len(s) if s.Sexista else ['background-color: green']*len(s)
60
+
61
 
62
  st.set_page_config(layout="wide")
63
  st.markdown('<style>body{background-color: Blue;}</style>',unsafe_allow_html=True)
 
66
  with colT2:
67
  #st.title('Analisis de comentarios sexistas en Twitter')
68
  st.markdown(""" <style> .font {
69
+ font-size:40px ; font-family: 'Cooper Black'; color: #FF9633;background-color: Blue;}
70
  </style> """, unsafe_allow_html=True)
71
  st.markdown('<p class="font">Análisis de comentarios sexistas en Twitter</p>', unsafe_allow_html=True)
72
 
 
155
  flat_predictions = np.argmax(flat_predictions, axis=1).flatten()#p = [i for i in classifier(tweet_list)]
156
  df = pd.DataFrame(list(zip(tweet_list, flat_predictions)),columns =['Últimos '+ str(number_of_tweets)+' Tweets'+' de '+search_words, 'Sexista'])
157
  df['Sexista']= np.where(df['Sexista']== 0, 'No Sexista', 'Sexista')
158
+
159
+ st.dataframe(df.style.apply(highlight_survived, axis=1))
160
+ #st.table(df)
161
  #st.write(df)
162
  run()