Alignments

In order to compute alignments, we first discover a Petri Net from the patients_complete dataset.

patients_complete <- patients %>% filter_lifecycle("complete")
model <- discovery_inductive(patients_complete)

As described here, this is a list containing a Petri net, an initial marking, and a final marking.

str(model)
## List of 3
##  $ petrinet       :List of 4
##   ..$ places     :'data.frame':  8 obs. of  1 variable:
##   .. ..$ id: chr [1:8] "source" "sink" "p_5" "p_6" ...
##   ..$ transitions:'data.frame':  10 obs. of  2 variables:
##   .. ..$ id   : chr [1:10] "skip_2" "Discuss Results" "skip_1" "Triage and Assessment" ...
##   .. ..$ label: chr [1:10] NA "Discuss Results" NA "Triage and Assessment" ...
##   ..$ flows      :'data.frame':  20 obs. of  2 variables:
##   .. ..$ from: chr [1:20] "skip_1" "p_4" "p_5" "MRI SCAN" ...
##   .. ..$ to  : chr [1:20] "p_5" "skip_1" "MRI SCAN" "p_6" ...
##   ..$ marking    : chr "source"
##   ..- attr(*, "class")= chr "petrinet"
##  $ initial_marking: chr "source"
##  $ final_marking  : chr "sink"

Alignments can be computed using conformance_alignment, using the log and the discovered model as inputs.

conformance_alignment(patients_complete, model$petrinet, model$inital_marking, model$final_marking) %>%
  head()
##   case_id                    log_id              model_id
## 1       1          t_Registration_0          Registration
## 2       1 t_Triage and Assessment_1 Triage and Assessment
## 3       1            t_Blood test_2            Blood test
## 4       1              t_MRI SCAN_3              MRI SCAN
## 5       1                        >>                skip_3
## 6       1       t_Discuss Results_4       Discuss Results
##               log_label           model_label cost visited_states
## 1          Registration          Registration    1              8
## 2 Triage and Assessment Triage and Assessment    1              8
## 3            Blood test            Blood test    1              8
## 4              MRI SCAN              MRI SCAN    1              8
## 5                    >>                  <NA>    1              8
## 6       Discuss Results       Discuss Results    1              8
##   queued_states traversed_arcs fitness
## 1            21             23       1
## 2            21             23       1
## 3            21             23       1
## 4            21             23       1
## 5            21             23       1
## 6            21             23       1

Quality Metrics

Quality metrics can also be computed

evaluation_fitness(patients_complete, model$petrinet, model$inital_marking, model$final_marking)
## $perc_fit_traces
## [1] 0
## 
## $average_trace_fitness
## [1] 0.9182714
## 
## $log_fitness
## [1] 0.9207211
evaluation_precision(patients_complete, model$petrinet, model$inital_marking, model$final_marking)
## [1] 0
evaluation_all(patients_complete, model$petrinet, model$inital_marking, model$final_marking)
## $fitness
## $fitness$perc_fit_traces
## [1] 0
## 
## $fitness$average_trace_fitness
## [1] 0.9182714
## 
## $fitness$log_fitness
## [1] 0.9207211
## 
## 
## $precision
## [1] 0
## 
## $generalization
## [1] 0.9439686
## 
## $simplicity
## [1] 0.5555556
## 
## $metricsAverageWeight
## [1] 0.6050613