Quality criteria for separate PM models are now exported for subdata

This commit is contained in:
Nora Wickelmaier 2023-12-22 15:35:51 +01:00
parent 0a533d7deb
commit 4d17f76fd5

View File

@ -20,10 +20,6 @@ event_log = pm4py.format_dataframe(dat, case_id='trace', activity_key='event',
timestamp_key='date.start') timestamp_key='date.start')
event_log = event_log.rename(columns={'artwork': 'case:artwork'}) event_log = event_log.rename(columns={'artwork': 'case:artwork'})
#event_log = pm4py.convert_to_event_log(dat_log) # deprecated #event_log = pm4py.convert_to_event_log(dat_log) # deprecated
start_activities = pm4py.get_start_activities(event_log)
start_activities
end_activities = pm4py.get_end_activities(event_log)
end_activities
###### Process Mining - complete data set ##### ###### Process Mining - complete data set #####
@ -50,6 +46,7 @@ pm4py.vis.view_petri_net(net, im, fm)
pm4py.vis.save_vis_petri_net(net, im, fm, "../figures/processmaps/pn_heuristics_complete.png") pm4py.vis.save_vis_petri_net(net, im, fm, "../figures/processmaps/pn_heuristics_complete.png")
is_sound = pm4py.check_soundness(net, im, fm) is_sound = pm4py.check_soundness(net, im, fm)
is_sound[0]
# decorated petri net # decorated petri net
from pm4py.visualization.petri_net import visualizer as pn_visualizer from pm4py.visualization.petri_net import visualizer as pn_visualizer
@ -67,6 +64,9 @@ a_eval = eval_pm(event_log, net, im, fm)
pm4py.vis.view_petri_net(net, im, fm) pm4py.vis.view_petri_net(net, im, fm)
pm4py.vis.save_vis_petri_net(net, im, fm, "../figures/processmaps/pn_alpha_complete.png") pm4py.vis.save_vis_petri_net(net, im, fm, "../figures/processmaps/pn_alpha_complete.png")
is_sound = pm4py.check_soundness(net, im, fm)
is_sound[0]
## Inductive Miner ## Inductive Miner
net, im, fm = pm4py.discover_petri_net_inductive(event_log) net, im, fm = pm4py.discover_petri_net_inductive(event_log)
i_eval = eval_pm(event_log, net, im, fm) i_eval = eval_pm(event_log, net, im, fm)
@ -77,12 +77,17 @@ pm4py.vis.save_vis_petri_net(net, im, fm, "../figures/processmaps/pn_induction_c
pt = pm4py.discover_process_tree_inductive(event_log) pt = pm4py.discover_process_tree_inductive(event_log)
pm4py.vis.view_process_tree(pt) pm4py.vis.view_process_tree(pt)
is_sound = pm4py.check_soundness(net, im, fm)
is_sound[0]
## ILP Miner ## ILP Miner
net, im, fm = pm4py.discover_petri_net_ilp(event_log) net, im, fm = pm4py.discover_petri_net_ilp(event_log)
ilp_eval = eval_pm(event_log, net, im, fm) ilp_eval = eval_pm(event_log, net, im, fm)
pm4py.vis.view_petri_net(net, im, fm) pm4py.vis.view_petri_net(net, im, fm)
pm4py.vis.save_vis_petri_net(net, im, fm, "../figures/processmaps/pn_ilp_complete.png") pm4py.vis.save_vis_petri_net(net, im, fm, "../figures/processmaps/pn_ilp_complete.png")
is_sound = pm4py.check_soundness(net, im, fm)
is_sound[0]
eval = pd.DataFrame(np.row_stack([h_eval, a_eval, i_eval, ilp_eval])) eval = pd.DataFrame(np.row_stack([h_eval, a_eval, i_eval, ilp_eval]))
eval.columns = ["fitness", "precision", "generalizability", "simplicity"] eval.columns = ["fitness", "precision", "generalizability", "simplicity"]
@ -99,7 +104,8 @@ net, im, fm = pm4py.discover_petri_net_heuristics(event_log)
def pm_artworks(miner): def pm_artworks(miner):
retval = np.empty((len(event_log["case:artwork"].unique()), 4)) retval1 = np.empty((len(event_log["case:artwork"].unique()), 4))
retval2 = np.empty((len(event_log["case:artwork"].unique()), 4))
if miner == "heuristics": if miner == "heuristics":
net, im, fm = pm4py.discover_petri_net_heuristics(event_log) net, im, fm = pm4py.discover_petri_net_heuristics(event_log)
@ -125,12 +131,19 @@ def pm_artworks(miner):
subnet, subim, subfm = pm4py.discover_petri_net_ilp(subdata) subnet, subim, subfm = pm4py.discover_petri_net_ilp(subdata)
pm4py.save_vis_petri_net(subnet, subim, subfm, pm4py.save_vis_petri_net(subnet, subim, subfm,
"../figures/processmaps/artworks/petrinet_" + miner + "_" + str(artwork).zfill(3) + ".png") "../figures/processmaps/artworks/petrinet_" + miner + "_" + str(artwork).zfill(3) + ".png")
retval[i] = eval_pm(subdata, net, im, fm) retval1[i] = eval_pm(subdata, net, im, fm)
retval2[i] = eval_pm(subdata, subnet, subim, subfm)
retval1 = pd.DataFrame(retval1)
retval1.columns = ["fitness", "precision", "generalizability", "simplicity"]
retval1.index = event_log["case:artwork"].unique()
retval1.insert(0, "nettype", "alldata")
retval2 = pd.DataFrame(retval2)
retval2.columns = ["fitness", "precision", "generalizability", "simplicity"]
retval2.index = event_log["case:artwork"].unique()
retval2.insert(0, "nettype", "subdata")
return pd.concat([retval1, retval2])
retval = pd.DataFrame(retval)
retval.columns = ["fitness", "precision", "generalizability", "simplicity"]
retval.index = event_log["case:artwork"].unique()
return retval
for miner in ["heuristics", "inductive", "alpha", "ilp"]: for miner in ["heuristics", "inductive", "alpha", "ilp"]:
eval_art = pm_artworks(miner = miner) eval_art = pm_artworks(miner = miner)