Spaces:
Runtime error
Runtime error
Commit
·
12c27ac
1
Parent(s):
3832023
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,12 +5,12 @@ from huggingface_hub import create_repo
|
|
| 5 |
|
| 6 |
dataset = load_dataset("torileatherman/sentiment_analysis_batch_predictions", split='train')
|
| 7 |
predictions_df = pd.DataFrame(dataset)
|
| 8 |
-
grouped_predictions = predictions_df.groupby(predictions_df.
|
| 9 |
-
|
| 10 |
-
|
| 11 |
negative_preds = grouped_predictions.get_group(0)
|
| 12 |
|
| 13 |
-
predictions_df['
|
| 14 |
|
| 15 |
|
| 16 |
def article_selection(sentiment):
|
|
@@ -18,27 +18,27 @@ def article_selection(sentiment):
|
|
| 18 |
predictions = negative_preds
|
| 19 |
top3 = predictions[0:3]
|
| 20 |
top3_result = top3[['Headline_string','Url']]
|
| 21 |
-
top3_result.rename(columns = {'
|
| 22 |
return top3_result
|
| 23 |
|
| 24 |
elif sentiment == "Negative":
|
| 25 |
predictions = negative_preds
|
| 26 |
top3 = predictions[0:3]
|
| 27 |
top3_result = top3[['Headline_string','Url']]
|
| 28 |
-
top3_result.rename(columns = {'
|
| 29 |
return top3_result
|
| 30 |
else:
|
| 31 |
predictions = negative_preds
|
| 32 |
top3 = predictions[0:3]
|
| 33 |
top3_result = top3[['Headline_string','Url']]
|
| 34 |
-
top3_result.rename(columns = {'
|
| 35 |
return top3_result
|
| 36 |
|
| 37 |
def manual_label():
|
| 38 |
# Selecting random row from batch data
|
| 39 |
random_sample = predictions_df.sample()
|
| 40 |
random_headline = random_sample['Headline_string'].iloc[0]
|
| 41 |
-
random_prediction = random_sample['
|
| 42 |
return random_headline, random_prediction
|
| 43 |
|
| 44 |
def thanks(sentiment):
|
|
|
|
| 5 |
|
| 6 |
dataset = load_dataset("torileatherman/sentiment_analysis_batch_predictions", split='train')
|
| 7 |
predictions_df = pd.DataFrame(dataset)
|
| 8 |
+
grouped_predictions = predictions_df.groupby(predictions_df.Prediction)
|
| 9 |
+
positive_preds = grouped_predictions.get_group(2)
|
| 10 |
+
neutral_preds = grouped_predictions.get_group(1)
|
| 11 |
negative_preds = grouped_predictions.get_group(0)
|
| 12 |
|
| 13 |
+
predictions_df['Prediction'] = predictions_df['Prediction'].map({0: 'Negative', 1: 'Neutral', 2: 'Positive'})
|
| 14 |
|
| 15 |
|
| 16 |
def article_selection(sentiment):
|
|
|
|
| 18 |
predictions = negative_preds
|
| 19 |
top3 = predictions[0:3]
|
| 20 |
top3_result = top3[['Headline_string','Url']]
|
| 21 |
+
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
| 22 |
return top3_result
|
| 23 |
|
| 24 |
elif sentiment == "Negative":
|
| 25 |
predictions = negative_preds
|
| 26 |
top3 = predictions[0:3]
|
| 27 |
top3_result = top3[['Headline_string','Url']]
|
| 28 |
+
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
| 29 |
return top3_result
|
| 30 |
else:
|
| 31 |
predictions = negative_preds
|
| 32 |
top3 = predictions[0:3]
|
| 33 |
top3_result = top3[['Headline_string','Url']]
|
| 34 |
+
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
| 35 |
return top3_result
|
| 36 |
|
| 37 |
def manual_label():
|
| 38 |
# Selecting random row from batch data
|
| 39 |
random_sample = predictions_df.sample()
|
| 40 |
random_headline = random_sample['Headline_string'].iloc[0]
|
| 41 |
+
random_prediction = random_sample['Prediction'].iloc[0]
|
| 42 |
return random_headline, random_prediction
|
| 43 |
|
| 44 |
def thanks(sentiment):
|