pm4py.ml.extract_temporal_features_dataframe#

pm4py.ml.extract_temporal_features_dataframe(log: EventLog | DataFrame, grouper_freq: str = 'W', activity_key: str = 'concept:name', timestamp_key: str = 'time:timestamp', case_id_key: str | None = None, start_timestamp_key: str = 'time:timestamp', resource_key: str = 'org:resource') DataFrame[source]#

Extracts temporal features from a log object and returns them as a dataframe.

This function computes temporal metrics based on the specified grouping frequency, which can be daily (D), weekly (W), monthly (M), or yearly (Y). These features are useful for analyzing system dynamics and simulation in the context of process mining.

The approach is based on: Pourbafrani, Mahsa, Sebastiaan J. van Zelst, and Wil MP van der Aalst. “Supporting automatic system dynamics model generation for simulation in the context of process mining.” International Conference on Business Information Systems. Springer, Cham, 2020.

Parameters:
  • log – The event log or Pandas DataFrame from which to extract temporal features.

  • grouper_freq (str) – The frequency to use for grouping (e.g., ‘D’ for daily, ‘W’ for weekly, ‘M’ for monthly, ‘Y’ for yearly).

  • activity_key (str) – Attribute to be used as the activity identifier.

  • timestamp_key (str) – Attribute to be used for timestamps.

  • case_id_key – (Optional) Attribute to be used as the case identifier. If not provided, the default is used.

  • start_timestamp_key (str) – Attribute to be used as the start timestamp.

  • resource_key (str) – Attribute to be used as the resource identifier.

Returns:

A Pandas DataFrame containing the extracted temporal features.

Return type:

pd.DataFrame

import pm4py

temporal_features_df = pm4py.extract_temporal_features_dataframe(
    dataframe,
    activity_key='concept:name',
    case_id_key='case:concept:name',
    timestamp_key='time:timestamp'
)