def discover_organizational_roles(log: Union[EventLog, pd.DataFrame]): """ Mines the organizational roles Parameters --------------- log Event log or Pandas dataframe Returns --------------- roles Organizational roles. List where each role is a sublist with two elements: - The first element of the sublist is the list of activities belonging to a role. Each activity belongs to a single role - The second element of the sublist is a dictionary containing the resources of the role and the number of times they executed activities belonging to the role. """ if type(log) not in [pd.DataFrame, EventLog, EventStream]: raise Exception("the method can be applied only to a traditional event log!") from pm4py.algo.organizational_mining.roles import algorithm as roles if check_is_pandas_dataframe(log): check_pandas_dataframe_columns(log) return roles.apply(log, variant=roles.Variants.PANDAS, parameters=get_properties(log)) else: return roles.apply(log, variant=roles.Variants.LOG, parameters=get_properties(log))
def discover_organizational_roles(log: Union[EventLog, pd.DataFrame]): """ Mines the organizational roles Parameters --------------- log Event log or Pandas dataframe Returns --------------- roles Organizational roles. List where each role is a sublist with two elements: - The first element of the sublist is the list of activities belonging to a role. Each activity belongs to a single role - The second element of the sublist is a dictionary containing the resources of the role and the number of times they executed activities belonging to the role. """ from pm4py.algo.organizational_mining.roles import algorithm as roles if check_is_dataframe(log): check_dataframe_columns(log) return roles.apply(log, variant=roles.Variants.PANDAS) else: return roles.apply(log, variant=roles.Variants.LOG)
def test_log_orgmining_local_roles(self): from pm4py.algo.organizational_mining.local_diagnostics import algorithm from pm4py.algo.organizational_mining.roles import algorithm as roles_detection log = xes_importer.apply(os.path.join("input_data", "receipt.xes")) roles = roles_detection.apply(log) algorithm.apply_from_clustering_or_roles(log, roles)
def test_role_receipt_xes(self): log = xes_importer.apply(os.path.join("..", "tests", "input_data", "receipt.xes")) roles = role_mining.apply(log)
def test_role_receipt_csv(self): df = pd.read_csv(os.path.join("input_data", "receipt.csv")) df = dataframe_utils.convert_timestamp_columns_in_df(df) roles = role_mining.apply(df)
def test_role_running_xes(self): log = xes_importer.apply(os.path.join("..", "tests", "input_data", "running-example.xes")) roles = role_mining.apply(log)