torileatherman commited on
Commit
2b0d3f5
1 Parent(s): 9415939

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -21,13 +21,19 @@ predictions_df['Sentiment'] = predictions_df['Sentiment'].map({0: 'Negative', 1:
21
  def article_selection(sentiment):
22
  if sentiment == "Positive":
23
  predictions = negative_preds
24
- predictions_df_url0 = predictions['Url'].iloc[0]
25
- predictions_df_head0 = predictions['Headlines_string'].iloc[0]
26
- predictions_df_url1 = predictions['Url'].iloc[1]
27
- predictions_df_head1 = predictions['Headlines_string'].iloc[1]
28
- predictions_df_url2 = predictions['Url'].iloc[2]
29
- predictions_df_head2 = predictions['Headlines_string'].iloc[2]
30
- return [[predictions_df_head0, predictions_df_url0], [predictions_df_head1, predictions_df_url1], [predictions_df_head2, predictions_df_url2]]
 
 
 
 
 
 
31
  elif sentiment == "Negative":
32
  predictions = negative_preds
33
  predictions_df_url0 = predictions['Url'].iloc[0]
 
21
  def article_selection(sentiment):
22
  if sentiment == "Positive":
23
  predictions = negative_preds
24
+ top3 = predictions[0:3]
25
+ top3_result = top3[['Headline_string','Url']]
26
+ top3_result.rename(columns = {'Headline_str':'Headlines', 'Url':'URL'})
27
+ # predictions_df_url0 = predictions['Url'].iloc[0]
28
+ # predictions_df_head0 = predictions['Headline_string'].iloc[0]
29
+ # predictions_df_url1 = predictions['Url'].iloc[1]
30
+ # predictions_df_head1 = predictions['Headline_string'].iloc[1]
31
+ # predictions_df_url2 = predictions['Url'].iloc[2]
32
+ # predictions_df_head2 = predictions['Headline_string'].iloc[2]
33
+ # predictions_df = [[predictions_df_head0, predictions_df_url0], [predictions_df_head1, predictions_df_url1], [predictions_df_head2, predictions_df_url2]]
34
+ # negative_df = pd.DataFrame(negative_df, columns=['Headline','URL'])
35
+ return top3_result
36
+
37
  elif sentiment == "Negative":
38
  predictions = negative_preds
39
  predictions_df_url0 = predictions['Url'].iloc[0]