pm4py_version. — version • pm4pypm4py_version.R/package.R
113 | version.RdThis function is deprecated, please use pm4py_version.
version()
121 |
122 |
123 | package_version S3 class
126 | 127 |NEWS.md
111 | This package provides access to the Python Process Mining library PM4PY in R 119 | and provides conversion between bupaR and PM4PY data structures.
120 |pm4py
123 |
124 |
125 | An object of class python.builtin.module (inherits from python.builtin.object) of length 2.
To use this package, you need to have a Python environment (Conda or virtualenv)
131 | installed and install the PM4PY package and its dependencies. You can use
132 | the convenience function install_pm4py to let reticulate take care of
133 | install the right version. See the documentation of this function for further
134 | information.
When loaded, the object pm4py provides the low-level interface to the main
136 | PM4PY module. Use $ to access sub modules of PM4PY as described in the
137 | reticulate documentation:
vignette("calling_python", package = "reticulate")
For parts of PM4PY wrapper functions are provided to transparently convert 140 | parameters and results to and from the corresponding bupaR S3 classes.
141 | 142 |148 |# Print the PM4PY version loaded 144 | if (pm4py_available()) { 145 | print(pm4py$`__version__`) 146 | }#> [1] "1.2.7"147 |
Convenience methods to use as PM4Py parameter keys.
118 |param_activity_key(value) 121 | 122 | param_attribute_key(value) 123 | 124 | param_timestamp_key(value) 125 | 126 | param_caseid_key(value) 127 | 128 | param_resource_key(value) 129 | 130 | default_parameters(eventlog)131 | 132 |
| value | 137 |The value to add to the list. |
138 |
|---|---|
| eventlog | 141 |A bupaR or PM4PY event log. |
142 |
a list with the parameter key/value pair
148 | 149 |165 |param_activity_key("activity")#> $`pm4py:param:activity_key` 151 | #> [1] "activity" 152 | #>#> $`pm4py:param:activity_key` 156 | #> [1] "handling" 157 | #> 158 | #> $`pm4py:param:timestamp_key` 159 | #> [1] "time" 160 | #> 161 | #> $case_id_glue 162 | #> [1] "patient" 163 | #>164 |
Converts a character vector of place identifiers to a PM4Py marking object.
118 |as_pm4py_marking(x, petrinet)121 | 122 |
| x | 127 |A character vector with (possible duplicate) place identifiers. |
128 |
|---|---|
| petrinet | 131 |A PM4Py Petri net. |
132 |
148 |if (pm4py_available()) { 138 | library(eventdataR) 139 | data(patients) 140 | 141 | # As Inductive Miner of PM4PY is not life-cycle aware, keep only `complete` events: 142 | patients_completes <- patients[patients$registration_type == "complete", ] 143 | 144 | net <- discovery_inductive(patients_completes) 145 | as_pm4py_marking(c("sink"), r_to_py(net$petrinet)) 146 | }#> ['sink:1']147 |
Checks if the Petri net is a Workflow net
118 |petrinet_check_wfnet(pn, convert = TRUE)121 | 122 |
| pn | 127 |Petri net |
128 |
|---|---|
| convert | 131 |
|
132 |
A single logical
138 | 139 |151 |if (pm4py_available()) { 141 | library(eventdataR) 142 | data(patients) 143 | 144 | # As Inductive Miner of PM4PY is not life-cycle aware, keep only `complete` events: 145 | patients_completes <- patients[patients$registration_type == "complete", ] 146 | 147 | net <- discovery_inductive(patients_completes) 148 | petrinet_check_wfnet(net$petrinet) 149 | 150 | }#> [1] TRUE
Write Petri net as PNML
118 |write_pnml(petrinet, file, initial_marking = NULL, final_marking = NULL)121 | 122 |
| petrinet | 127 |A bupaR or PM4PY Petri net. |
128 |
|---|---|
| file | 131 |File name of the PNML file |
132 |
| initial_marking | 135 |A R vector with the place identifiers of the initial marking or a PM4PY marking. 136 | By default the initial marking of the bupaR Petri net will be used if available. |
137 |
| final_marking | 140 |A R vector with the place identifiers of the final marking or a PM4PY marking. |
141 |
162 |# don't test automatically since this writes a file 147 | # \donttest{ 148 | if (pm4py_available()) { 149 | library(eventdataR) 150 | data(patients) 151 | 152 | # As Inductive Miner of PM4PY is not life-cycle aware, keep only `complete` events: 153 | patients_completes <- patients[patients$registration_type == "complete", ] 154 | 155 | net <- discovery_inductive(patients_completes) 156 | write_pnml(net$petrinet, 157 | "test.pnml", 158 | net$initial_marking, 159 | net$final_marking) 160 | } 161 | # }
R/petrinet.R
113 | petrinet_check_relaxed_soundness.RdChecks if the Petri net is relaxed sound
118 |petrinet_check_relaxed_soundness(pn, im = NULL, fm = NULL, convert = TRUE)121 | 122 |
| pn | 127 |Petri net |
128 |
|---|---|
| im | 131 |Initial marking of the Petri net (optional for workflow nets) |
132 |
| fm | 135 |Final marking of the Petri net (optional for workflow nets) |
136 |
| convert | 139 |
|
140 |
A single logical
146 | 147 |159 |if (pm4py_available()) { 149 | library(eventdataR) 150 | data(patients) 151 | 152 | # As Inductive Miner of PM4PY is not life-cycle aware, keep only `complete` events: 153 | patients_completes <- patients[patients$registration_type == "complete", ] 154 | 155 | net <- discovery_inductive(patients_completes) 156 | petrinet_check_relaxed_soundness(net$petrinet) 157 | 158 | }#> [1] TRUE
Installs the pm4py package and its dependencies using pip since no
122 | Conda package is available. Further information on the parameters can
123 | be found in the reticulate package documentation:
124 | https://rstudio.github.io/reticulate/
125 | In some cases (multiple Python versions installed) it might be useful to specify the exact path to the conda binary.
install_pm4py(method = "auto", conda = "auto", version = NULL, ...)129 | 130 |
| method | 135 |Installation method. By default, "auto" automatically finds a method that will work in the local environment. 136 | Change the default to force a specific installation method. Note that the "virtualenv" method is not available on Windows. |
137 |
|---|---|
| conda | 140 |Path to conda executable (or "auto" to find conda using the PATH and other conventional install locations). |
141 |
| version | 144 |Optional parameter overriding the PM4Py version that will be installed. Note that the R pm4py package was only tested against the default PM4Py version that will be installed. |
145 |
| ... | 148 |Additional arguments passed to py_install(). |
149 |
Additional requirements, for example, a C++ compiler and GraphViz might 155 | need to be installed to leverage all functionality. Please refer to the PM4Py documentation for details: 156 | https://pm4py.fit.fraunhofer.de/install
157 | 158 |168 |# \donttest{ 160 | pm4py::install_pm4py() 161 | 162 | # Specify path to conda 163 | pm4py::install_pm4py(method = "conda", conda = "/home/user/miniconda3/bin/conda") 164 | 165 | # Install specific version of PM4Py 166 | pm4py::install_pm4py(version = "1.2.7") 167 | # }