baakaani commited on
Commit
2b39384
·
1 Parent(s): 1120efa

changes to similairty metric and addition of progress bar

Browse files
Files changed (2) hide show
  1. gedi/utils/io_helpers.py +7 -3
  2. utils/config_fabric.py +14 -11
gedi/utils/io_helpers.py CHANGED
@@ -86,7 +86,11 @@ def dump_features_json(features: dict, output_path, content_type="features"):
86
 
87
  def compute_similarity(v1, v2):
88
 
89
- # HOTFIX: Rename 'ratio_unique_traces_per_trace
 
 
 
 
90
  if 'ratio_unique_traces_per_trace' in v1:
91
  v1['ratio_variants_per_number_of_traces'] = v1.pop('ratio_unique_traces_per_trace')
92
 
@@ -104,7 +108,7 @@ def compute_similarity(v1, v2):
104
 
105
  else:
106
  # Calculate Euclidean Similarity
107
- target_similarity = 1-euclidean(vec1, vec2)
108
- #print("VECTORS: ", vec1, vec2, target_similarity)
109
 
110
  return target_similarity
 
86
 
87
  def compute_similarity(v1, v2):
88
 
89
+ # Convert all values to float except for the value for the key "Log"
90
+ v1 = {k: (float(v) if k != "log" else v) for k, v in v1.items()}
91
+ v2 = {k: (float(v) if k != "log" else v) for k, v in v2.items()}
92
+
93
+ # HOTFIX: Rename 'ratio_unique_traces_per_trace'
94
  if 'ratio_unique_traces_per_trace' in v1:
95
  v1['ratio_variants_per_number_of_traces'] = v1.pop('ratio_unique_traces_per_trace')
96
 
 
108
 
109
  else:
110
  # Calculate Euclidean Similarity
111
+ target_similarity = 1 / (1 + euclidean(vec1, vec2))
112
+ # print("VECTORS: ", vec1, vec2, target_similarity)
113
 
114
  return target_similarity
utils/config_fabric.py CHANGED
@@ -4,15 +4,13 @@ from itertools import product as cproduct
4
  from itertools import combinations
5
  from pathlib import Path
6
  from pylab import *
7
- import itertools
8
  import json
9
  import math
10
  import os
11
  import pandas as pd
12
- import pm4py
13
- import random
14
  import streamlit as st
15
  import subprocess
 
16
 
17
  st.set_page_config(layout='wide')
18
  INPUT_XES="output/inputlog_temp.xes"
@@ -272,6 +270,7 @@ if __name__ == '__main__':
272
  #save_labels = ["Save configuration file"]
273
  create_button, create_run_button = multi_button(save_labels)
274
  #create_button = multi_button(save_labels)
 
275
  if create_button or create_run_button:
276
  with open(output_path, "w") as f:
277
  f.write(config_file)
@@ -281,21 +280,21 @@ if __name__ == '__main__':
281
  st.code(var, language='bash')
282
 
283
  if create_run_button:
284
- #if False: #FIXME: Command fails when using multiprocessing
285
  command = var.split()
 
 
 
 
 
 
286
 
287
- # Run the command
288
  result = subprocess.run(command, capture_output=True, text=True)
289
  st.write("## Results")
290
  st.write(*step_config['generator_params']['experiment'][0].keys(), "log name", "target similarity")
291
 
292
- #if len(result.stderr)==0:
293
- # st.write(result.stdout)
294
- #else:
295
- # st.write("ERROR: ", result.stderr)
296
-
297
  directory = Path(step_config['output_path']).parts
298
- path = os.path.join(directory[0],'features',*directory[1:])
299
 
300
  # Walk through all directories and files
301
  for root, dirs, files in os.walk(path):
@@ -310,3 +309,7 @@ if __name__ == '__main__':
310
  # Print the contents of the JSON file
311
  st.write(*config_targets.values(), data['log'], data['target_similarity'])
312
 
 
 
 
 
 
4
  from itertools import combinations
5
  from pathlib import Path
6
  from pylab import *
 
7
  import json
8
  import math
9
  import os
10
  import pandas as pd
 
 
11
  import streamlit as st
12
  import subprocess
13
+ import time
14
 
15
  st.set_page_config(layout='wide')
16
  INPUT_XES="output/inputlog_temp.xes"
 
270
  #save_labels = ["Save configuration file"]
271
  create_button, create_run_button = multi_button(save_labels)
272
  #create_button = multi_button(save_labels)
273
+
274
  if create_button or create_run_button:
275
  with open(output_path, "w") as f:
276
  f.write(config_file)
 
280
  st.code(var, language='bash')
281
 
282
  if create_run_button:
 
283
  command = var.split()
284
+ progress_bar = st.progress(0) # Initialize the progress bar
285
+
286
+ # Simulate running the command with a loop and updating the progress bar
287
+ for i in range(95):
288
+ time.sleep(0.1) # Simulate the time taken for each step
289
+ progress_bar.progress(i + 1)
290
 
291
+ # Run the actual command
292
  result = subprocess.run(command, capture_output=True, text=True)
293
  st.write("## Results")
294
  st.write(*step_config['generator_params']['experiment'][0].keys(), "log name", "target similarity")
295
 
 
 
 
 
 
296
  directory = Path(step_config['output_path']).parts
297
+ path = os.path.join(directory[0], 'features', *directory[1:])
298
 
299
  # Walk through all directories and files
300
  for root, dirs, files in os.walk(path):
 
309
  # Print the contents of the JSON file
310
  st.write(*config_targets.values(), data['log'], data['target_similarity'])
311
 
312
+ # Optional: Updating the progress bar to indicate completion
313
+ progress_bar.progress(100)
314
+
315
+