Updated PM for case clusters and rerun it with precision
This commit is contained in:
		
							parent
							
								
									4174162dfe
								
							
						
					
					
						commit
						d4f5aa427d
					
				| @ -24,7 +24,7 @@ event_log = pm4py.format_dataframe(dat, | ||||
| 
 | ||||
| #--------------- (2) Evaluation for clusters --------------- | ||||
| 
 | ||||
| thresholds = [0.0, 0.1, 0.2, 0.3, 0.4] | ||||
| thresholds = [0.1, 0.2, 0.3, 0.4] | ||||
| 
 | ||||
| for nt in thresholds: | ||||
| 
 | ||||
| @ -33,9 +33,9 @@ for nt in thresholds: | ||||
|     eval = eval_append(event_log, net, im, fm) | ||||
| 
 | ||||
|     # Export process maps | ||||
|     pm4py.save_vis_petri_net(net, im, fm, "results/processmaps/petrinet_complete_cases" + str(int(nt*10)).zfill(2) + ".png") | ||||
|     bpmn = pm4py.convert.convert_to_bpmn(net, im, fm) | ||||
|     pm4py.vis.save_vis_bpmn(bpmn, "results/processmaps/bpmn_complete_cases" + str(int(nt*10)).zfill(2) + ".png") | ||||
|     # pm4py.save_vis_petri_net(net, im, fm, "results/processmaps/petrinet_complete_cases" + str(int(nt*10)).zfill(2) + ".png") | ||||
|     # bpmn = pm4py.convert.convert_to_bpmn(net, im, fm) | ||||
|     # pm4py.vis.save_vis_bpmn(bpmn, "results/processmaps/bpmn_complete_cases" + str(int(nt*10)).zfill(2) + ".png") | ||||
| 
 | ||||
|     # Merge clusters into data frame | ||||
|     for cluster in [1, 2, 3, 4, 5]: | ||||
| @ -44,9 +44,9 @@ for nt in thresholds: | ||||
|         eval_clst = eval_append(log_clst, net_clst, im_clst, fm_clst) | ||||
|         eval = pd.concat([eval, eval_clst]) | ||||
|         # Export process maps | ||||
|         pm4py.save_vis_petri_net(net_clst, im_clst, fm_clst, "results/processmaps/petrinet_cluster" + str(cluster) + "_cases" + str(int(nt*10)).zfill(2) + ".png") | ||||
|         bpmn = pm4py.convert.convert_to_bpmn(net_clst, im_clst, fm_clst) | ||||
|         pm4py.vis.save_vis_bpmn(bpmn, "results/processmaps/bpmn_cluster" + str(cluster) + "_cases" + str(int(nt*10)).zfill(2) + ".png") | ||||
|         # pm4py.save_vis_petri_net(net_clst, im_clst, fm_clst, "results/processmaps/petrinet_cluster" + str(cluster) + "_cases" + str(int(nt*10)).zfill(2) + ".png") | ||||
|         # bpmn = pm4py.convert.convert_to_bpmn(net_clst, im_clst, fm_clst) | ||||
|         # pm4py.vis.save_vis_bpmn(bpmn, "results/processmaps/bpmn_cluster" + str(cluster) + "_cases" + str(int(nt*10)).zfill(2) + ".png") | ||||
| 
 | ||||
|     eval.index = ["Complete", "Cluster 1", "Cluster 2", "Cluster 3", "Cluster 4", "Cluster 5"] | ||||
|     eval.to_csv("results/eval_case_clusters_" + str(int(nt*10)).zfill(2) + ".csv", sep = ";") | ||||
|  | ||||
| @ -7,15 +7,15 @@ def eval_pm(data, net, initial_marking, final_marking): | ||||
|     """Caculate fitness, precision, generalization, and simplicity for petri net""" | ||||
|     print("Fitness is calculated") | ||||
|     fitness          = pm4py.fitness_token_based_replay(data, net, initial_marking, final_marking) | ||||
|     #print("Precision is calculated") | ||||
|     #precisison       = pm4py.precision_token_based_replay(data, net, initial_marking, final_marking) | ||||
|     print("Precision is calculated") | ||||
|     precisison       = pm4py.precision_token_based_replay(data, net, initial_marking, final_marking) | ||||
|     print("Generalizability is calculated") | ||||
|     generalization = pm4py.algo.evaluation.generalization.algorithm.apply(data, net, | ||||
|                                                                             initial_marking, final_marking) | ||||
|     print("Simplicity is calculated") | ||||
|     simplicity       = pm4py.algo.evaluation.simplicity.algorithm.apply(net) | ||||
|     #return [fitness['average_trace_fitness'], precisison, generalization, simplicity] | ||||
|     return [fitness['average_trace_fitness'], generalization, simplicity] | ||||
|     return [fitness['average_trace_fitness'], precisison, generalization, simplicity] | ||||
|     #return [fitness['average_trace_fitness'], generalization, simplicity] | ||||
| 
 | ||||
| 
 | ||||
| def pn_infos(log, colname, filter): | ||||
| @ -63,7 +63,8 @@ def eval_append(log, net, im, fm): | ||||
|     eval.append({k: sorted_variants[k] for k in list(sorted_variants)[:1]}) | ||||
| 
 | ||||
|     eval = pd.DataFrame(eval).T | ||||
|     eval.columns = ["fitness", "generalization", "simplicity", "narcs", "ntrans", "nplaces", "nvariants", "mostfreq"] | ||||
|     #eval.columns = ["fitness", "generalization", "simplicity", "narcs", "ntrans", "nplaces", "nvariants", "mostfreq"] | ||||
|     #eval.columns = ["fitness", "precision", "generalization", "simplicity", "sound", "narcs", "ntrans", "nplaces", "nvariants", "mostfreq"] | ||||
|     eval.columns = ["fitness", "precision", "generalization", "simplicity", "narcs", "ntrans", "nplaces", "nvariants", "mostfreq"] | ||||
|     return eval | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user