Spaces:
Runtime error
Runtime error
Commit
·
b510a14
1
Parent(s):
b4d720e
Update app.py
Browse files
app.py
CHANGED
@@ -26,6 +26,7 @@ n = 5
|
|
26 |
def article_selection(sentiment):
|
27 |
if sentiment == "Positive":
|
28 |
predictions = positive_preds
|
|
|
29 |
top3 = predictions[0:n]
|
30 |
top3_result = top3[['Headline_string','Url']]
|
31 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
@@ -33,12 +34,14 @@ def article_selection(sentiment):
|
|
33 |
|
34 |
elif sentiment == "Negative":
|
35 |
predictions = negative_preds
|
|
|
36 |
top3 = predictions[0:n]
|
37 |
top3_result = top3[['Headline_string','Url']]
|
38 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
39 |
return top3_result
|
40 |
else:
|
41 |
predictions = neutral_preds
|
|
|
42 |
top3 = predictions[0:n]
|
43 |
top3_result = top3[['Headline_string','Url']]
|
44 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
|
|
26 |
def article_selection(sentiment):
|
27 |
if sentiment == "Positive":
|
28 |
predictions = positive_preds
|
29 |
+
predictions_shuffled = predictions.sample(frac=1,weights=predictions['Confidence'])
|
30 |
top3 = predictions[0:n]
|
31 |
top3_result = top3[['Headline_string','Url']]
|
32 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
|
|
34 |
|
35 |
elif sentiment == "Negative":
|
36 |
predictions = negative_preds
|
37 |
+
predictions_shuffled = predictions.sample(frac=1,weights=predictions['Confidence'])
|
38 |
top3 = predictions[0:n]
|
39 |
top3_result = top3[['Headline_string','Url']]
|
40 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
41 |
return top3_result
|
42 |
else:
|
43 |
predictions = neutral_preds
|
44 |
+
predictions_shuffled = predictions.sample(frac=1,weights=predictions['Confidence'])
|
45 |
top3 = predictions[0:n]
|
46 |
top3_result = top3[['Headline_string','Url']]
|
47 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|