Andrea Maldonado commited on
Commit
b49ce56
·
1 Parent(s): c55374f

Working: Fixes experimental test

Browse files
Files changed (1) hide show
  1. tag/benchmark.py +13 -5
tag/benchmark.py CHANGED
@@ -40,14 +40,15 @@ class BenchmarkTest:
40
  if params != None:
41
  self.params = params
42
 
 
43
 
44
  if True:
45
  num_cores = multiprocessing.cpu_count() if len(
46
  event_logs) >= multiprocessing.cpu_count() else len(event_logs)
47
- #self.benchmark_wrapper(event_logs[0], miners=self.params[MINERS])# TESTING
48
  with multiprocessing.Pool(num_cores) as p:
49
  print(f"INFO: Benchmark starting at {start.strftime('%H:%M:%S')} using {num_cores} cores for {len(event_logs)} files...")
50
- p.map(partial(self.benchmark_wrapper, miners = self.params[MINERS]), event_logs)
51
 
52
  # Aggregates metafeatures in saved Jsons into dataframe
53
  self.root_path = self.params[INPUT_PATH]
@@ -76,7 +77,10 @@ class BenchmarkTest:
76
  f" and {len(benchmark_results)} event-logs. Saved benchmark to {self.filepath}.")
77
  print("========================= ~ BenchmarkTest =============================")
78
 
79
- def benchmark_wrapper(self, event_log="test", miners=['inductive']):
 
 
 
80
  dump_path = os.path.join(self.params[OUTPUT_PATH],
81
  os.path.split(self.params[INPUT_PATH])[-1])
82
  dump_path= os.path.join(self.params[OUTPUT_PATH],
@@ -88,8 +92,10 @@ class BenchmarkTest:
88
  benchmark_results = pd.DataFrame()
89
  # TODO: Use iteratevely generated name for log name in dataframe for passed unnamed logs instead of whole log. E.g. gen_el_1, gen_el_2,...
90
  if isinstance(event_log, str):
91
- results = {'log': event_log.replace(".xes", "")}
 
92
  else:
 
93
  results = {"log": event_log}
94
 
95
  for miner in miners:
@@ -103,8 +109,10 @@ class BenchmarkTest:
103
  results[f"pnsize_{miner}"]=benchmark_results[4]
104
  results[f"cfc_{miner}"]=benchmark_results[3]
105
 
 
 
106
  print(f" SUCCESS: {miner} miner for {results} took {dt.now()-start_miner} sec.")
107
- dump_features_json(results, dump_path, event_log.replace(".xes",""), content_type="benchmark")
108
  return
109
 
110
  def split_miner_wrapper(self, log_path="data/real_event_logs/BPI_Challenges/BPI_Challenge_2012.xes"):
 
40
  if params != None:
41
  self.params = params
42
 
43
+ log_counter = [*range(0,len(event_logs))]
44
 
45
  if True:
46
  num_cores = multiprocessing.cpu_count() if len(
47
  event_logs) >= multiprocessing.cpu_count() else len(event_logs)
48
+ #self.benchmark_wrapper((event_logs[0],0), miners=self.params[MINERS])# TESTING
49
  with multiprocessing.Pool(num_cores) as p:
50
  print(f"INFO: Benchmark starting at {start.strftime('%H:%M:%S')} using {num_cores} cores for {len(event_logs)} files...")
51
+ p.map(partial(self.benchmark_wrapper, miners = self.params[MINERS]), zip(event_logs, log_counter))
52
 
53
  # Aggregates metafeatures in saved Jsons into dataframe
54
  self.root_path = self.params[INPUT_PATH]
 
77
  f" and {len(benchmark_results)} event-logs. Saved benchmark to {self.filepath}.")
78
  print("========================= ~ BenchmarkTest =============================")
79
 
80
+ def benchmark_wrapper(self, event_log, miners=['inductive']):
81
+ log_counter = event_log[1]
82
+ event_log = event_log[0]
83
+
84
  dump_path = os.path.join(self.params[OUTPUT_PATH],
85
  os.path.split(self.params[INPUT_PATH])[-1])
86
  dump_path= os.path.join(self.params[OUTPUT_PATH],
 
92
  benchmark_results = pd.DataFrame()
93
  # TODO: Use iteratevely generated name for log name in dataframe for passed unnamed logs instead of whole log. E.g. gen_el_1, gen_el_2,...
94
  if isinstance(event_log, str):
95
+ log_name = event_log.replace(".xes", "")
96
+ results = {'log': log_name}
97
  else:
98
+ log_name = "gen_el_"+str(log_counter)
99
  results = {"log": event_log}
100
 
101
  for miner in miners:
 
109
  results[f"pnsize_{miner}"]=benchmark_results[4]
110
  results[f"cfc_{miner}"]=benchmark_results[3]
111
 
112
+ results['log'] = log_name
113
+
114
  print(f" SUCCESS: {miner} miner for {results} took {dt.now()-start_miner} sec.")
115
+ dump_features_json(results, dump_path, log_name, content_type="benchmark")
116
  return
117
 
118
  def split_miner_wrapper(self, log_path="data/real_event_logs/BPI_Challenges/BPI_Challenge_2012.xes"):