pm4py.algo.transformation.trace_encodings.variants.event_based module#

PM4Py – A Process Mining Library for Python Copyright (C) 2026 Process Intelligence Solutions GmbH

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see this software project’s root or visit <https://www.gnu.org/licenses/>.

Website: https://processintelligence.solutions Contact: info@processintelligence.solutions

class pm4py.algo.transformation.trace_encodings.variants.event_based.Parameters(*values)[source]#

Bases: Enum

STR_EVENT_ATTRIBUTES = 'str_ev_attr'#
NUM_EVENT_ATTRIBUTES = 'num_ev_attr'#
FEATURE_NAMES = 'feature_names'#
MIN_NUM_DIFF_STR_VALUES = 'min_num_diff_str_values'#
MAX_NUM_DIFF_STR_VALUES = 'max_num_diff_str_values'#
pm4py.algo.transformation.trace_encodings.variants.event_based.extract_all_ev_features_names_from_log(log: EventLog, str_ev_attr: List[str], num_ev_attr: List[str], parameters: Dict[str | Parameters, Any] | None = None) → List[str][source]#

Extracts the feature names from an event log.

Parameters:
  • log – Event log

  • str_ev_attr – (if provided) list of string event attributes to consider in extracting the feature names

  • num_ev_attr – (if provided) list of integer event attributes to consider in extracting the feature names

  • parameters –

    Parameters, including:
    • MIN_NUM_DIFF_STR_VALUES => minimum number of distinct values to include an attribute as feature(s)

    • MAX_NUM_DIFF_STR_VALUES => maximum number of distinct values to include an attribute as feature(s)

Returns:

List of feature names

Return type:

feature_names

pm4py.algo.transformation.trace_encodings.variants.event_based.extract_features(log: EventLog, feature_names: List[str], parameters: Dict[str | Parameters, Any] | None = None) → Tuple[Any, List[str]][source]#

Extracts the matrix of the features from an event log

Parameters:
  • log – Event log

  • feature_names – Features to consider (in the given order)

Returns:

  • data – Data to provide for decision tree learning

  • feature_names – Names of the features, in order

pm4py.algo.transformation.trace_encodings.variants.event_based.apply(log: EventLog, parameters: Dict[str | Parameters, Any] | None = None) → Tuple[Any, List[str]][source]#

Encodes each event in each trace as a feature vector.

From an event-log point of view, the result keeps the trace/event grid: each trace becomes a sequence of event vectors, padded to the maximum trace length in the log. String event attributes are one-hot encoded; numeric event attributes are copied as numeric values.

Example with event attribute “concept:name”:

case 1: A, B case 2: A

The vocabulary is [event:concept:name@A, event:concept:name@B]. If the maximum trace length is 2, the encoded tensor is:

case 1 -> [[1, 0], [0, 1]] case 2 -> [[1, 0], [0, 0]]

Parameters:
  • log – Event log

  • parameters –

    Parameters of the algorithm, including:
    • STR_EVENT_ATTRIBUTES => string event attributes to consider in the features extraction

    • NUM_EVENT_ATTRIBUTES => numeric event attributes to consider in the features extraction

    • FEATURE_NAMES => features to consider (in the given order)

Returns:

  • data – Data to provide for decision tree learning

  • feature_names – Names of the features, in order