Roles Detection

Role Detection

An excellent article on roles detection, that has inspired the technique implemented in PM4Py, is:

Burattin, Andrea, Alessandro Sperduti, and Marco Veluscek. “Business models enhancement through discovery of roles.”¬†2013 IEEE Symposium on Computational Intelligence and Data Mining (CIDM). IEEE, 2013.

What is a role

A role is a set of activities in the log that are executed by a similar (multi)set of resources. Hence, it is a specific function into organization. Grouping the activities in roles can help:

  • In understanding which activities are executed by which roles
  • By understanding roles itself (numerosity of resources for a single activity may not provide enough explanation)

How the algorithm works

Initially, each activity corresponds to a different role, and is associated to the multiset of his originators. After that, roles are merged according to their similarity, until no more merges are possible.

How to apply the algorithm

First, you need to import a log or a dataframe:

from pm4py.objects.log.importer.xes import factory as xes_importer
import os
log = xes_importer.apply(os.path.join("tests", "input_data", "receipt.xes"))
from pm4py.objects.log.adapters.pandas import csv_import_adapter
import os
df = csv_import_adapter.import_dataframe_from_path(os.path.join("tests", "input_data", "receipt.csv"))

After that, the role detection algorithm can be applied:

from pm4py.algo.enhancement.roles import factory as roles_factory
roles = roles_factory.apply(log)

We can print the sets of activities that are grouped in roles by doing print([x[0] for x in roles]) and obtaining:

[[‘Confirmation of receipt’, ‘T02 Check confirmation of receipt’, ‘T06 Determine necessity of stop advice’, ‘T10 Determine necessity to stop indication’], [‘T03 Adjust confirmation of receipt’], [‘T04 Determine confirmation of receipt’], [‘T05 Print and send confirmation of receipt’], [‘T07-1 Draft intern advice aspect 1’], [‘T07-2 Draft intern advice aspect 2’], [‘T07-3 Draft intern advice hold for aspect 3’], [‘T07-4 Draft internal advice to hold for type 4’], [‘T07-5 Draft intern advice aspect 5’], [‘T08 Draft and send request for advice’], [‘T09-1 Process or receive external advice from party 1’], [‘T09-2 Process or receive external advice from party 2’], [‘T09-3 Process or receive external advice from party 3’], [‘T09-4 Process or receive external advice from party 4’], [‘T11 Create document X request unlicensed’, ‘T12 Check document X request unlicensed’], [‘T13 Adjust document X request unlicensed’], [‘T14 Determine document X request unlicensed’], [‘T15 Print document X request unlicensed’], [‘T16 Report reasons to hold request’, ‘T17 Check report Y to stop indication’, ‘T19 Determine report Y to stop indication’, ‘T20 Print report Y to stop indication’], [‘T18 Adjust report Y to stop indicition’]]

.