torileatherman commited on
Commit
e831013
·
1 Parent(s): 58f8ede

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -1,13 +1,7 @@
1
  import gradio as gr
2
- import hopsworks
3
  from datasets import load_dataset
4
  import pandas as pd
5
 
6
- project = hopsworks.login()
7
- fs = project.get_feature_store()
8
-
9
- dataset_api = project.get_dataset_api()
10
-
11
  dataset = load_dataset("torileatherman/sentiment_analysis_batch_predictions", split='train')
12
  predictions_df = pd.DataFrame(dataset)
13
  grouped_predictions = predictions_df.groupby(predictions_df.Sentiment)
@@ -47,6 +41,10 @@ def manual_label():
47
  return random_headline, random_prediction
48
 
49
  def thanks(sentiment):
 
 
 
 
50
  return f"""Thank you for making our model better!"""
51
 
52
 
@@ -73,6 +71,11 @@ with gr.Blocks() as manual_label_demo:
73
  description = description2
74
  generate_btn = gr.Button('Show me a headline!')
75
  generate_btn.click(fn=manual_label, outputs=[gr.Textbox(label="News Headline"),gr.Textbox(label="Our Predicted Sentiment")])
 
 
 
 
 
76
  drop_down_label = gr.Dropdown(["Positive","Negative","Neutral"], label="Select the true sentiment of the news article.")
77
  submit_btn = gr.Button('Submit your sentiment!')
78
  submit_btn.click(fn=thanks, inputs=drop_down_label, outputs=gr.Textbox())
 
1
  import gradio as gr
 
2
  from datasets import load_dataset
3
  import pandas as pd
4
 
 
 
 
 
 
5
  dataset = load_dataset("torileatherman/sentiment_analysis_batch_predictions", split='train')
6
  predictions_df = pd.DataFrame(dataset)
7
  grouped_predictions = predictions_df.groupby(predictions_df.Sentiment)
 
41
  return random_headline, random_prediction
42
 
43
  def thanks(sentiment):
44
+ labeled_sentiments = []
45
+ labeled_sentiments.append(sentiment)
46
+ counter = len(labeled_sentiments)
47
+ labeled_sentiments.write_to_directory("torileatherman/labeled_data_"+counter+"/")
48
  return f"""Thank you for making our model better!"""
49
 
50
 
 
71
  description = description2
72
  generate_btn = gr.Button('Show me a headline!')
73
  generate_btn.click(fn=manual_label, outputs=[gr.Textbox(label="News Headline"),gr.Textbox(label="Our Predicted Sentiment")])
74
+ nested - gr.Interface(
75
+ inputs = gr.Dropdown(["Positive","Negative","Neutral"], label="Select the true sentiment of the news article.")
76
+ outputs = gr.Textbox()
77
+ fn =
78
+ )
79
  drop_down_label = gr.Dropdown(["Positive","Negative","Neutral"], label="Select the true sentiment of the news article.")
80
  submit_btn = gr.Button('Submit your sentiment!')
81
  submit_btn.click(fn=thanks, inputs=drop_down_label, outputs=gr.Textbox())