suryadev1 commited on
Commit
6841b7c
Β·
1 Parent(s): 447391b

added the changes for visualizing hyperlink

Browse files
app.py CHANGED
@@ -115,17 +115,17 @@ def process_file(model_name,inc_slider,progress=Progress(track_tqdm=True)):
115
  opt_task_groups = ['opt_task1' if test_info.loc[idx, 6] == 0 else 'opt_task2' for idx in selected_rows_df2.index]
116
  progress(0.2, desc="Files create and saved!! Now Executing models")
117
  print("finetuned task: ",finetune_task)
118
- subprocess.run([
119
- "python", "new_test_saved_finetuned_model.py",
120
- "-workspace_name", "ratio_proportion_change3_2223/sch_largest_100-coded",
121
- "-finetune_task", finetune_task,
122
- "-test_dataset_path","../../../../fileHandler/selected_rows.txt",
123
- # "-test_label_path","../../../../train_label.txt",
124
- "-finetuned_bert_classifier_checkpoint",
125
- "ratio_proportion_change3_2223/sch_largest_100-coded/output/highGRschool10/bert_fine_tuned.model.ep42",
126
- "-e",str(1),
127
- "-b",str(1000)
128
- ])
129
  progress(0.5,desc="Model execution completed!! Now performing analysis on the results")
130
 
131
  # Load tlb and plb
@@ -181,7 +181,11 @@ def process_file(model_name,inc_slider,progress=Progress(track_tqdm=True)):
181
  filtered_data = filtered_data[filtered_data[6] == task_type] # Ensure test_info[6] matches
182
 
183
  # Define filename dynamically
184
- filename = f"output_task{task_type}_label{label}.csv"
 
 
 
 
185
 
186
  # Write to CSV
187
  process_and_write_csv(filtered_data, filename)
@@ -1096,12 +1100,27 @@ FILE_DIR = "fileHandler"
1096
 
1097
  # Function to get list of files
1098
  def list_files():
1099
- return ['output_task0_label0.csv', 'output_task0_label1.csv', 'output_task1_label0.csv', 'output_task1_label1.csv']
 
1100
  # return [f for f in os.listdir(FILE_DIR) if os.path.isfile(os.path.join(FILE_DIR, f))]
1101
-
 
 
 
 
 
1102
  # Function to provide the selected file path
1103
- def provide_file_path(file_name):
1104
- return f"{FILE_DIR}/{file_name}" if file_name else None
 
 
 
 
 
 
 
 
 
1105
  # file_path = os.path.join(FILE_DIR, file_name)
1106
  # return file_path
1107
 
@@ -1152,13 +1171,14 @@ with gr.Blocks(theme='gstaff/sketch', css=custom_css) as demo:
1152
  # output_text_sampled_auc = gr.Textbox(label="")
1153
 
1154
  with gr.Row():
1155
- file_dropdown = gr.Dropdown(choices=list_files(), label="Generate File")
1156
- download_button = gr.Button("Generate files")
1157
-
 
1158
  download_button.click(
1159
  fn=provide_file_path,
1160
  inputs=[file_dropdown],
1161
- outputs=[gr.File(label="Your Download is ready, click on the right side to download")]
1162
  )
1163
 
1164
  btn.click(
 
115
  opt_task_groups = ['opt_task1' if test_info.loc[idx, 6] == 0 else 'opt_task2' for idx in selected_rows_df2.index]
116
  progress(0.2, desc="Files create and saved!! Now Executing models")
117
  print("finetuned task: ",finetune_task)
118
+ # subprocess.run([
119
+ # "python", "new_test_saved_finetuned_model.py",
120
+ # "-workspace_name", "ratio_proportion_change3_2223/sch_largest_100-coded",
121
+ # "-finetune_task", finetune_task,
122
+ # "-test_dataset_path","../../../../fileHandler/selected_rows.txt",
123
+ # # "-test_label_path","../../../../train_label.txt",
124
+ # "-finetuned_bert_classifier_checkpoint",
125
+ # "ratio_proportion_change3_2223/sch_largest_100-coded/output/highGRschool10/bert_fine_tuned.model.ep42",
126
+ # "-e",str(1),
127
+ # "-b",str(1000)
128
+ # ])
129
  progress(0.5,desc="Model execution completed!! Now performing analysis on the results")
130
 
131
  # Load tlb and plb
 
181
  filtered_data = filtered_data[filtered_data[6] == task_type] # Ensure test_info[6] matches
182
 
183
  # Define filename dynamically
184
+ task_type_map = {0: "ER", 1: "ME"}
185
+ label_map = {0: "unsuccessful", 1: "successful"}
186
+
187
+ filename = f"{task_type_map[task_type]}-{label_map[label]}-strategies.csv"
188
+
189
 
190
  # Write to CSV
191
  process_and_write_csv(filtered_data, filename)
 
1100
 
1101
  # Function to get list of files
1102
  def list_files():
1103
+ return ['Unsuccessful Strategies (ER)', 'Successful Strategies (ER)', 'Unsuccessful Strategies (ME)', 'Successful Strategies (ME)']
1104
+ # return ['output_task0_label0.csv', 'output_task0_label1.csv', 'output_task1_label0.csv', 'output_task1_label1.csv']
1105
  # return [f for f in os.listdir(FILE_DIR) if os.path.isfile(os.path.join(FILE_DIR, f))]
1106
+ label_to_filename = {
1107
+ 'Unsuccessful Strategies (ER)': 'ER-unsuccessful-strategies.csv',
1108
+ 'Successful Strategies (ER)': 'ER-successful-strategies.csv',
1109
+ 'Unsuccessful Strategies (ME)': 'ME-unsuccessful-strategies.csv',
1110
+ 'Successful Strategies (ME)': 'ME-successful-strategies.csv'
1111
+ }
1112
  # Function to provide the selected file path
1113
+ def provide_file_path(label_name):
1114
+ file_name=label_to_filename.get(label_name, None)
1115
+ dynamic_text = (
1116
+ "πŸ” [Visualize the strategies](https://path-analysis.vercel.app/)\n\n"
1117
+
1118
+ "To use the demo, please follow these steps:\n"
1119
+ "πŸ“„ Generate strategies from the AI model and visualize the strategies `.csv` files "
1120
+ "using the path analysis web-app. Refer to the user guide for more details on how to interpret "
1121
+ "the strategy visualization."
1122
+ )
1123
+ return f"{FILE_DIR}/{file_name}" if file_name else None, gr.update(visible=True,value=dynamic_text)
1124
  # file_path = os.path.join(FILE_DIR, file_name)
1125
  # return file_path
1126
 
 
1171
  # output_text_sampled_auc = gr.Textbox(label="")
1172
 
1173
  with gr.Row():
1174
+ file_dropdown = gr.Dropdown(choices=list_files(), label="Select a strategy from the dropdown")
1175
+ download_button = gr.Button("Generate Strategies")
1176
+ generated_textbox = gr.Markdown( visible=False)
1177
+
1178
  download_button.click(
1179
  fn=provide_file_path,
1180
  inputs=[file_dropdown],
1181
+ outputs=[gr.File(label=""), generated_textbox]
1182
  )
1183
 
1184
  btn.click(
fileHandler/ER-successful-strategies.csv ADDED
The diff for this file is too large to render. See raw diff
 
fileHandler/ER-unsuccessful-strategies.csv ADDED
The diff for this file is too large to render. See raw diff
 
fileHandler/ME-successful-strategies.csv ADDED
The diff for this file is too large to render. See raw diff
 
fileHandler/ME-unsuccessful-strategies.csv ADDED
The diff for this file is too large to render. See raw diff
 
fileHandler/result.txt CHANGED
@@ -3,5 +3,5 @@ total_acc: 69.00702106318957
3
  precisions: 0.7236623191454734
4
  recalls: 0.6900702106318957
5
  f1_scores: 0.6802420656474512
6
- time_taken_from_start: 36.14206862449646
7
  auc_score: 0.7457100293916334
 
3
  precisions: 0.7236623191454734
4
  recalls: 0.6900702106318957
5
  f1_scores: 0.6802420656474512
6
+ time_taken_from_start: 39.65812015533447
7
  auc_score: 0.7457100293916334