pm4py.objects.log.util.activities_to_alphabet module#

class pm4py.objects.log.util.activities_to_alphabet.Parameters(*values)[source]#

Bases: Enum

ACTIVITY_KEY = 'activity_key'#
RETURN_MAPPING = 'return_mapping'#
pm4py.objects.log.util.activities_to_alphabet.apply(dataframe: DataFrame, parameters: Dict[Any, Any] | None = None) DataFrame | Tuple[DataFrame, Dict[str, str]][source]#

Remap the activities in a dataframe using an augmented alphabet to minimize the size of the encoding

Running example:

import pm4py from pm4py.objects.log.util import activities_to_alphabet from pm4py.util import constants

dataframe = pm4py.read_xes(“tests/input_data/running-example.xes”) renamed_dataframe = activities_to_alphabet.apply(dataframe, parameters={constants.PARAMETER_CONSTANT_ACTIVITY_KEY: “concept:name”}) print(renamed_dataframe)

Parameters:
  • dataframe – Pandas dataframe

  • parameters – Parameters of the method, including: - Parameters.ACTIVITY_KEY => attribute to be used as activity - Parameters.RETURN_MAPPING => (boolean) enables the returning the mapping dictionary (so the original activities can be re-constructed)

Returns:

  • ren_dataframe – Pandas dataframe in which the activities have been remapped to the (augmented) alphabet

  • inv_mapping – (if required) Dictionary associating to every letter of the (augmented) alphabet the original activity