Interface to 'PM4py' < http://pm4py.org>, a process mining library in 'Python'. This package uses the 'reticulate' package to act as a bridge between 'PM4Py' and the 'R' package 'bupaR'. It provides several process discovery algorithms, evaluation measures, and alignments.
You can install the development version of pm4py with:
Then, automatically install the pm4py package in a virtual or Conda environment:
See the 'reticulate' documentation for more information on the available options or how to specify an existing Python environment: https://rstudio.github.io/reticulate/
library(pm4py)# Most of the data structures are converted in their bupaR equivalentslibrary(bupaR)# As Inductive Miner of PM4PY is not life-cycle aware, keep only `complete` events:patients_completes <- patients[patients$registration_type == "complete", ]# Discovery with Inductive Minerpn <- discovery_inductive(patients_completes)# This results in an auto-converted bupaR Petri net and markingsstr(pn)class(pn$petrinet)# Render with bupaRrender_PN(pn$petrinet)# Render with PM4PY and DiagrammeRlibrary(DiagrammeR)viz <- reticulate::import("pm4py.visualization.petrinet")# Convert back to Pythonpy_pn <- r_to_py(pn$petrinet)class(py_pn)# Render to DOT with PMP4Ydot <- viz$factory$apply(py_pn)$sourcegrViz(diagram = dot)# Compute alignmentalignment <- conformance_alignment(patients_completes, pn$petrinet, pn$initial_marking, pn$final_marking)# # Alignment is returned in long format as data framehead(alignment)# Evaluate model qualityquality <- evaluation_all(patients_completes, pn$petrinet, pn$initial_marking, pn$final_marking)