jayebaku commited on
Commit
9865cf1
·
verified ·
1 Parent(s): 05d925b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -41,7 +41,13 @@ def analyze_selected_texts(selections):
41
  result_df = pd.DataFrame({"Selected Text": selected_texts, "Analysis": analysis_results})
42
  return result_df
43
 
 
 
44
 
 
 
 
 
45
  with gr.Blocks() as demo:
46
  event_models = ["jayebaku/distilbert-base-multilingual-cased-crexdata-relevance-classifier"]
47
 
@@ -51,14 +57,14 @@ with gr.Blocks() as demo:
51
  # T4.5 Relevance Classifier Demo
52
  This is a demo created to explore floods and wildfire classification in social media posts.\n
53
  Usage:\n
54
- \tUpload .tsv data file (must contain a text column with social media posts).\n
55
- \tNext, type the name of the text column.\n
56
- \tThen, choose a BERT classifier model from the drop down.\n
57
- \tFinally, click the 'start classification' buttton.\n
58
  Evaluation:\n
59
- \tTo evaluate the model's accuracy select the INCORRECT classifications using the checkboxes in front of each post.\n
60
- \tThen, click on the 'Calculate Accuracy' button.\n
61
- \tThen, click on the 'Download data as CSV' to get the classifications and evaluation data as a .csv file.
62
  """)
63
  with gr.Row(equal_height=True):
64
  with gr.Column(scale=4):
@@ -82,10 +88,6 @@ with gr.Blocks() as demo:
82
  gr.Markdown("""### None""")
83
  none_checkbox_output = gr.CheckboxGroup(label="Select ONLY incorrect classifications", interactive=True)
84
 
85
- # model_confidence = gr.Number(label="Model Confidence")
86
- # predict_button.click(load_and_analyze_csv, inputs=[file_input, text_field, event_model],
87
- # outputs=[flood_checkbox_output, fire_checkbox_output, none_checkbox_output, model_confidence])
88
-
89
  with gr.Row(equal_height=True):
90
  with gr.Column(scale=5):
91
  gr.Markdown(r"""
@@ -106,8 +108,11 @@ with gr.Blocks() as demo:
106
  incorrect = gr.Number(label="Number of incorrect classifications", value=0)
107
  accuracy = gr.Number(label="Model Accuracy", value=0)
108
 
 
109
  predict_button.click(load_and_analyze_csv, inputs=[file_input, text_field, event_model],
110
  outputs=[flood_checkbox_output, fire_checkbox_output, none_checkbox_output, model_confidence])
 
 
111
 
112
  with gr.Tab("Question Answering"):
113
  # XXX Add some button disabling here, if the classification process is not completed first XXX
 
41
  result_df = pd.DataFrame({"Selected Text": selected_texts, "Analysis": analysis_results})
42
  return result_df
43
 
44
+ def calculate_accuracy(flood_selections, fire_selections, none_selections)
45
+ incorrect = len(flood_selections) + len(fire_selections) + len(none_selections)
46
 
47
+ return incorrect
48
+
49
+
50
+
51
  with gr.Blocks() as demo:
52
  event_models = ["jayebaku/distilbert-base-multilingual-cased-crexdata-relevance-classifier"]
53
 
 
57
  # T4.5 Relevance Classifier Demo
58
  This is a demo created to explore floods and wildfire classification in social media posts.\n
59
  Usage:\n
60
+ -Upload .tsv data file (must contain a text column with social media posts).\n
61
+ -Next, type the name of the text column.\n
62
+ -Then, choose a BERT classifier model from the drop down.\n
63
+ -Finally, click the 'start prediction' buttton.\n
64
  Evaluation:\n
65
+ -To evaluate the model's accuracy select the INCORRECT classifications using the checkboxes in front of each post.\n
66
+ -Then, click on the 'Calculate Accuracy' button.\n
67
+ -Then, click on the 'Download data as CSV' to get the classifications and evaluation data as a .csv file.
68
  """)
69
  with gr.Row(equal_height=True):
70
  with gr.Column(scale=4):
 
88
  gr.Markdown("""### None""")
89
  none_checkbox_output = gr.CheckboxGroup(label="Select ONLY incorrect classifications", interactive=True)
90
 
 
 
 
 
91
  with gr.Row(equal_height=True):
92
  with gr.Column(scale=5):
93
  gr.Markdown(r"""
 
108
  incorrect = gr.Number(label="Number of incorrect classifications", value=0)
109
  accuracy = gr.Number(label="Model Accuracy", value=0)
110
 
111
+ accuracy_button = gr.Button("Calculate Accuracy")
112
  predict_button.click(load_and_analyze_csv, inputs=[file_input, text_field, event_model],
113
  outputs=[flood_checkbox_output, fire_checkbox_output, none_checkbox_output, model_confidence])
114
+ accuracy_button.click(calculate_accuracy, inputs=[flood_checkbox_output, fire_checkbox_output, none_checkbox_output],
115
+ outputs=incorrect)
116
 
117
  with gr.Tab("Question Answering"):
118
  # XXX Add some button disabling here, if the classification process is not completed first XXX