Spaces:
Sleeping
Sleeping
implment changes for new design and count summary of test info
Browse files- app.py +92 -25
- plot.png +0 -0
- ratio_proportion_change3_2223/sch_largest_100-coded/finetuning/highGRschool10/test_label.txt +0 -0
- result.txt +7 -7
- roc_data.pkl +2 -2
- selected_rows.txt +0 -0
app.py
CHANGED
|
@@ -24,17 +24,19 @@ def process_file(model_name,inc_slider,progress=Progress(track_tqdm=True)):
|
|
| 24 |
# shutil.copyfile(label.name, saved_test_label)
|
| 25 |
# shutil.copyfile(info.name, saved_train_info)
|
| 26 |
parent_location="ratio_proportion_change3_2223/sch_largest_100-coded/finetuning/"
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
finetune_task="highGRschool10"
|
| 29 |
-
test_info_location=parent_location+"
|
| 30 |
-
test_location=parent_location+"
|
| 31 |
-
elif(model_name== "
|
| 32 |
finetune_task="lowGRschoolAll"
|
| 33 |
-
test_info_location=parent_location+"lowGRschoolAll/test_info.txt"
|
| 34 |
-
test_location=parent_location+"lowGRschoolAll/test.txt"
|
| 35 |
-
elif(model_name=="
|
| 36 |
-
test_info_location=parent_location+"
|
| 37 |
-
test_location=parent_location+"
|
| 38 |
finetune_task="highGRschool10"
|
| 39 |
else:
|
| 40 |
finetune_task=None
|
|
@@ -83,7 +85,74 @@ def process_file(model_name,inc_slider,progress=Progress(track_tqdm=True)):
|
|
| 83 |
# model_name="highGRschool10"
|
| 84 |
# else:
|
| 85 |
# model_name="highGRschool10"
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
subprocess.run([
|
| 88 |
"python", "new_test_saved_finetuned_model.py",
|
| 89 |
"-workspace_name", "ratio_proportion_change3_2223/sch_largest_100-coded",
|
|
@@ -113,7 +182,7 @@ def process_file(model_name,inc_slider,progress=Progress(track_tqdm=True)):
|
|
| 113 |
fig, ax = plt.subplots()
|
| 114 |
ax.plot(fpr, tpr, color='blue', lw=2, label=f'ROC curve (area = {roc_auc:.2f})')
|
| 115 |
ax.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')
|
| 116 |
-
ax.set(xlabel='False Positive Rate', ylabel='True Positive Rate', title=f'
|
| 117 |
ax.legend(loc="lower right")
|
| 118 |
ax.grid()
|
| 119 |
|
|
@@ -127,23 +196,20 @@ def process_file(model_name,inc_slider,progress=Progress(track_tqdm=True)):
|
|
| 127 |
# Prepare text output with HTML formatting
|
| 128 |
text_output = f"""
|
| 129 |
Model: {model_name}\n
|
| 130 |
-
Result Summary:\n
|
| 131 |
-----------------\n
|
| 132 |
-
|
| 133 |
-
Recall: {result['recalls']:.2f}\n
|
| 134 |
Time Taken: {result['time_taken_from_start']:.2f} seconds\n
|
| 135 |
Total Schools in test: {len(unique_schools):.4f}\n
|
| 136 |
Total Schools taken: {len(random_schools):.4f}\n
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-----------------\n
|
| 140 |
-
Note: The ROC Curve is also displayed for the evaluation.
|
| 141 |
"""
|
| 142 |
-
return text_output,plot_path
|
| 143 |
|
| 144 |
# List of models for the dropdown menu
|
| 145 |
|
| 146 |
-
models = ["
|
| 147 |
|
| 148 |
# Create the Gradio interface
|
| 149 |
with gr.Blocks(css="""
|
|
@@ -328,7 +394,7 @@ tbody.svelte-18wv37q>tr.svelte-18wv37q:nth-child(odd) {
|
|
| 328 |
color: white;
|
| 329 |
""") as demo:
|
| 330 |
gr.Markdown("<h1 id='title'>ASTRA</h1>", elem_id="title")
|
| 331 |
-
|
| 332 |
|
| 333 |
with gr.Row():
|
| 334 |
# file_input = gr.File(label="Upload a test file", file_types=['.txt'], elem_classes="file-box")
|
|
@@ -336,18 +402,19 @@ tbody.svelte-18wv37q>tr.svelte-18wv37q:nth-child(odd) {
|
|
| 336 |
|
| 337 |
# info_input = gr.File(label="Upload test info", file_types=['.txt'], elem_classes="file-box")
|
| 338 |
|
| 339 |
-
model_dropdown = gr.Dropdown(choices=models, label="Select
|
| 340 |
|
| 341 |
|
| 342 |
increment_slider = gr.Slider(minimum=1, maximum=100, step=1, label="Schools Percentage", value=1)
|
| 343 |
-
|
| 344 |
with gr.Row():
|
| 345 |
-
output_text = gr.Textbox(label="
|
| 346 |
-
output_image = gr.Image(label="
|
|
|
|
| 347 |
|
| 348 |
btn = gr.Button("Submit")
|
| 349 |
|
| 350 |
-
btn.click(fn=process_file, inputs=[model_dropdown,increment_slider], outputs=[output_text,output_image])
|
| 351 |
|
| 352 |
|
| 353 |
# Launch the app
|
|
|
|
| 24 |
# shutil.copyfile(label.name, saved_test_label)
|
| 25 |
# shutil.copyfile(info.name, saved_train_info)
|
| 26 |
parent_location="ratio_proportion_change3_2223/sch_largest_100-coded/finetuning/"
|
| 27 |
+
test_info_location=parent_location+"fullTest/test_info.txt"
|
| 28 |
+
test_location=parent_location+"fullTest/test.txt"
|
| 29 |
+
if(model_name=="ASTRA-FT-HGR"):
|
| 30 |
finetune_task="highGRschool10"
|
| 31 |
+
# test_info_location=parent_location+"fullTest/test_info.txt"
|
| 32 |
+
# test_location=parent_location+"fullTest/test.txt"
|
| 33 |
+
elif(model_name== "ASTRA-FT-LGR" ):
|
| 34 |
finetune_task="lowGRschoolAll"
|
| 35 |
+
# test_info_location=parent_location+"lowGRschoolAll/test_info.txt"
|
| 36 |
+
# test_location=parent_location+"lowGRschoolAll/test.txt"
|
| 37 |
+
elif(model_name=="ASTRA-FT-FULL"):
|
| 38 |
+
# test_info_location=parent_location+"fullTest/test_info.txt"
|
| 39 |
+
# test_location=parent_location+"fullTest/test.txt"
|
| 40 |
finetune_task="highGRschool10"
|
| 41 |
else:
|
| 42 |
finetune_task=None
|
|
|
|
| 85 |
# model_name="highGRschool10"
|
| 86 |
# else:
|
| 87 |
# model_name="highGRschool10"
|
| 88 |
+
# Function to analyze each row
|
| 89 |
+
def analyze_row(row):
|
| 90 |
+
# Split the row into fields
|
| 91 |
+
fields = row.split("\t")
|
| 92 |
+
|
| 93 |
+
# Define tasks for OptionalTask_1, OptionalTask_2, and FinalAnswer
|
| 94 |
+
optional_task_1_subtasks = ["DenominatorFactor", "NumeratorFactor", "EquationAnswer"]
|
| 95 |
+
optional_task_2_subtasks = [
|
| 96 |
+
"FirstRow2:1", "FirstRow2:2", "FirstRow1:1", "FirstRow1:2",
|
| 97 |
+
"SecondRow", "ThirdRow"
|
| 98 |
+
]
|
| 99 |
+
final_answer_tasks = ["FinalAnswer"]
|
| 100 |
+
|
| 101 |
+
# Helper function to evaluate task attempts
|
| 102 |
+
def evaluate_tasks(fields, tasks):
|
| 103 |
+
task_status = {}
|
| 104 |
+
for task in tasks:
|
| 105 |
+
relevant_attempts = [f for f in fields if task in f]
|
| 106 |
+
# print(relevant_attempts)
|
| 107 |
+
if any("OK" in attempt for attempt in relevant_attempts):
|
| 108 |
+
task_status[task] = "Attempted (Successful)"
|
| 109 |
+
elif any("ERROR" in attempt for attempt in relevant_attempts):
|
| 110 |
+
task_status[task] = "Attempted (Error)"
|
| 111 |
+
elif any("JIT" in attempt for attempt in relevant_attempts):
|
| 112 |
+
task_status[task] = "Attempted (JIT)"
|
| 113 |
+
else:
|
| 114 |
+
task_status[task] = "Unattempted"
|
| 115 |
+
return task_status
|
| 116 |
+
|
| 117 |
+
# Evaluate tasks for each category
|
| 118 |
+
optional_task_1_status = evaluate_tasks(fields, optional_task_1_subtasks)
|
| 119 |
+
optional_task_2_status = evaluate_tasks(fields, optional_task_2_subtasks)
|
| 120 |
+
final_answer_status = evaluate_tasks(fields, final_answer_tasks)
|
| 121 |
+
|
| 122 |
+
# Combine results
|
| 123 |
+
result = {
|
| 124 |
+
"OptionalTask_1": optional_task_1_status,
|
| 125 |
+
"OptionalTask_2": optional_task_2_status,
|
| 126 |
+
"FinalAnswer": final_answer_status,
|
| 127 |
+
}
|
| 128 |
+
return result
|
| 129 |
+
# Read data from test_info.txt
|
| 130 |
+
with open(test_info_location, "r") as file:
|
| 131 |
+
data = file.readlines()
|
| 132 |
+
results = [analyze_row(row.strip()) for row in data if row.strip()]
|
| 133 |
+
|
| 134 |
+
status_counts = {}
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
for result in results:
|
| 138 |
+
for task_category, task_statuses in result.items():
|
| 139 |
+
for task, status in task_statuses.items():
|
| 140 |
+
if task not in status_counts:
|
| 141 |
+
status_counts[task] = {"Attempted (Successful)": 0, "Attempted (Error)": 0,
|
| 142 |
+
"Attempted (JIT)": 0, "Unattempted": 0}
|
| 143 |
+
status_counts[task][status] += 1
|
| 144 |
+
|
| 145 |
+
# Create a string output for results
|
| 146 |
+
output_summary = "Task Analysis Summary:\n"
|
| 147 |
+
output_summary += "-----------------------\n"
|
| 148 |
+
|
| 149 |
+
for task, statuses in status_counts.items():
|
| 150 |
+
output_summary += f"Task: {task}\n"
|
| 151 |
+
for status, count in statuses.items():
|
| 152 |
+
output_summary += f" {status}: {count}\n"
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
progress(0.2, desc="analysis done!! Executing models")
|
| 156 |
subprocess.run([
|
| 157 |
"python", "new_test_saved_finetuned_model.py",
|
| 158 |
"-workspace_name", "ratio_proportion_change3_2223/sch_largest_100-coded",
|
|
|
|
| 182 |
fig, ax = plt.subplots()
|
| 183 |
ax.plot(fpr, tpr, color='blue', lw=2, label=f'ROC curve (area = {roc_auc:.2f})')
|
| 184 |
ax.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')
|
| 185 |
+
ax.set(xlabel='False Positive Rate', ylabel='True Positive Rate', title=f'(Receiver Operating Curve) ROC')
|
| 186 |
ax.legend(loc="lower right")
|
| 187 |
ax.grid()
|
| 188 |
|
|
|
|
| 196 |
# Prepare text output with HTML formatting
|
| 197 |
text_output = f"""
|
| 198 |
Model: {model_name}\n
|
|
|
|
| 199 |
-----------------\n
|
| 200 |
+
|
|
|
|
| 201 |
Time Taken: {result['time_taken_from_start']:.2f} seconds\n
|
| 202 |
Total Schools in test: {len(unique_schools):.4f}\n
|
| 203 |
Total Schools taken: {len(random_schools):.4f}\n
|
| 204 |
+
Total number of instances having Schools with HGR : {len(high_sample):.4f}\n
|
| 205 |
+
Total number of instances having Schools with LGR: {len(low_sample):.4f}\n
|
| 206 |
-----------------\n
|
|
|
|
| 207 |
"""
|
| 208 |
+
return text_output,plot_path,output_summary
|
| 209 |
|
| 210 |
# List of models for the dropdown menu
|
| 211 |
|
| 212 |
+
models = ["ASTRA-FT-HGR", "ASTRA-FT-LGR", "ASTRA-FT-FULL"]
|
| 213 |
|
| 214 |
# Create the Gradio interface
|
| 215 |
with gr.Blocks(css="""
|
|
|
|
| 394 |
color: white;
|
| 395 |
""") as demo:
|
| 396 |
gr.Markdown("<h1 id='title'>ASTRA</h1>", elem_id="title")
|
| 397 |
+
|
| 398 |
|
| 399 |
with gr.Row():
|
| 400 |
# file_input = gr.File(label="Upload a test file", file_types=['.txt'], elem_classes="file-box")
|
|
|
|
| 402 |
|
| 403 |
# info_input = gr.File(label="Upload test info", file_types=['.txt'], elem_classes="file-box")
|
| 404 |
|
| 405 |
+
model_dropdown = gr.Dropdown(choices=models, label="Select Fine-tuned Model", elem_classes="dropdown-menu")
|
| 406 |
|
| 407 |
|
| 408 |
increment_slider = gr.Slider(minimum=1, maximum=100, step=1, label="Schools Percentage", value=1)
|
| 409 |
+
gr.Markdown("<p class='description'>Dashboard</p>")
|
| 410 |
with gr.Row():
|
| 411 |
+
output_text = gr.Textbox(label="")
|
| 412 |
+
output_image = gr.Image(label="ROC")
|
| 413 |
+
output_summary = gr.Textbox(label="Summary")
|
| 414 |
|
| 415 |
btn = gr.Button("Submit")
|
| 416 |
|
| 417 |
+
btn.click(fn=process_file, inputs=[model_dropdown,increment_slider], outputs=[output_text,output_image,output_summary])
|
| 418 |
|
| 419 |
|
| 420 |
# Launch the app
|
plot.png
CHANGED
|
|
ratio_proportion_change3_2223/sch_largest_100-coded/finetuning/highGRschool10/test_label.txt
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
result.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
-
avg_loss: 0.
|
| 2 |
-
total_acc:
|
| 3 |
-
precisions: 0.
|
| 4 |
-
recalls: 0.
|
| 5 |
-
f1_scores: 0.
|
| 6 |
-
time_taken_from_start:
|
| 7 |
-
auc_score: 0.
|
|
|
|
| 1 |
+
avg_loss: 0.5820454359054565
|
| 2 |
+
total_acc: 69.02834008097166
|
| 3 |
+
precisions: 0.7233000757179396
|
| 4 |
+
recalls: 0.6902834008097166
|
| 5 |
+
f1_scores: 0.680564448931978
|
| 6 |
+
time_taken_from_start: 37.70641040802002
|
| 7 |
+
auc_score: 0.7527458335895701
|
roc_data.pkl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:57ef1d1fe518f78a1087a3605e61462c3489cfbd0e2b7cc7bc9cf4b6360b60f7
|
| 3 |
+
size 9917
|
selected_rows.txt
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|