Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,7 @@ def load_and_analyze_csv(file, text_field, event_model):
|
|
31 |
flood_related = gr.CheckboxGroup(choices=floods)
|
32 |
not_related = gr.CheckboxGroup(choices=nones)
|
33 |
|
34 |
-
return flood_related, fire_related, not_related, model_confidence
|
35 |
|
36 |
def analyze_selected_texts(selections):
|
37 |
selected_texts = selections
|
@@ -41,10 +41,11 @@ def analyze_selected_texts(selections):
|
|
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,
|
45 |
incorrect = len(flood_selections) + len(fire_selections) + len(none_selections)
|
46 |
-
|
47 |
-
|
|
|
48 |
|
49 |
|
50 |
|
@@ -110,9 +111,9 @@ with gr.Blocks() as demo:
|
|
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
|
|
|
31 |
flood_related = gr.CheckboxGroup(choices=floods)
|
32 |
not_related = gr.CheckboxGroup(choices=nones)
|
33 |
|
34 |
+
return flood_related, fire_related, not_related, model_confidence, len(df[text_field].to_list())
|
35 |
|
36 |
def analyze_selected_texts(selections):
|
37 |
selected_texts = selections
|
|
|
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_selection, num_posts):
|
45 |
incorrect = len(flood_selections) + len(fire_selections) + len(none_selections)
|
46 |
+
correct = num_posts - incorrect
|
47 |
+
accuracy = (correct/num_posts)*100
|
48 |
+
return incorrect, correct, accuracy
|
49 |
|
50 |
|
51 |
|
|
|
111 |
|
112 |
accuracy_button = gr.Button("Calculate Accuracy")
|
113 |
predict_button.click(load_and_analyze_csv, inputs=[file_input, text_field, event_model],
|
114 |
+
outputs=[flood_checkbox_output, fire_checkbox_output, none_checkbox_output, model_confidence, number_posts])
|
115 |
+
accuracy_button.click(calculate_accuracy, inputs=[flood_checkbox_output, fire_checkbox_output, none_checkbox_output, num_posts],
|
116 |
+
outputs=[incorrect, correct, accuracy])
|
117 |
|
118 |
with gr.Tab("Question Answering"):
|
119 |
# XXX Add some button disabling here, if the classification process is not completed first XXX
|