suryadev1 commited on
Commit
3e6c9e6
Β·
2 Parent(s): 1b7a3da 890efcc
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py CHANGED
@@ -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(
 
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/.DS_Store ADDED
Binary file (6.15 kB). View file
 
fileHandler/output_task0_label0.csv DELETED
The diff for this file is too large to render. See raw diff
 
fileHandler/output_task0_label1.csv DELETED
The diff for this file is too large to render. See raw diff
 
fileHandler/output_task1_label0.csv DELETED
The diff for this file is too large to render. See raw diff
 
fileHandler/output_task1_label1.csv DELETED
The diff for this file is too large to render. See raw diff
 
fileHandler/result.txt CHANGED
@@ -3,5 +3,9 @@ total_acc: 69.00702106318957
3
  precisions: 0.7236623191454734
4
  recalls: 0.6900702106318957
5
  f1_scores: 0.6802420656474512
 
6
  time_taken_from_start: 2.1567678451538086
 
 
 
7
  auc_score: 0.7457100293916334
 
3
  precisions: 0.7236623191454734
4
  recalls: 0.6900702106318957
5
  f1_scores: 0.6802420656474512
6
+ <<<<<<< HEAD
7
  time_taken_from_start: 2.1567678451538086
8
+ =======
9
+ time_taken_from_start: 39.65812015533447
10
+ >>>>>>> 890efcc1f23279edda21b3cc2f50174aea7ddb43
11
  auc_score: 0.7457100293916334
fileHandler/roc_data.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2483f35aa06ef8983623602f690eb3fe006654c79d448f4f82a913b4862e34e9
3
- size 9437
 
 
 
 
fileHandler/roc_data2.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0578bbc08b428a1f54707fc3aca6aa1063e045033cb007f8ba3361f1aace43df
3
- size 28023