pm4py.util.variants_util 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.util.variants_util.Parameters(*values)[source]#

Bases: Enum

ACTIVITY_KEY = 'pm4py:param:activity_key'#
PARAMETER_VARIANT_DELIMITER = 'variant_delimiter'#
pm4py.util.variants_util.variant_to_trace(variant, parameters=None)[source]#
pm4py.util.variants_util.get_activities_from_variant(variant, parameters=None)[source]#
pm4py.util.variants_util.get_variant_from_trace(trace, parameters=None)[source]#
pm4py.util.variants_util.aggregate_consecutive_activities_in_variants(variants: Dict[Collection[str], int | List], max_repetitions: int = 1) → Dict[Collection[str], int | List][source]#

Aggregate the consecutive activities in the variant.

For example, {(‘A’, ‘B’, ‘C’): 3, (‘A’, ‘B’, ‘B’, ‘B’, ‘C’): 2, (‘A’, ‘B’, ‘B’, ‘B’, ‘B’, ‘B’, ‘C’): 1} Would be reduced to: - {(‘A’, ‘B’, ‘C’): 6} if max_repetitions=1 - {(‘A’, ‘B’, ‘C’): 3, (‘A’, ‘B’, ‘B’, ‘C’): 3} if max_repetitions=2 - {(‘A’, ‘B’, ‘C’): 3, (‘A’, ‘B’, ‘B’, ‘B’, ‘C’): 3} if max_repetitions=3 - {(‘A’, ‘B’, ‘C’): 3, (‘A’, ‘B’, ‘B’, ‘B’, ‘C’): 2, (‘A’, ‘B’, ‘B’, ‘B’, ‘B’, ‘C’): 1} if max_repetitions=4

Parameters:
  • variants – Dictionary of variants (where each variant is associated to its count (pd.DataFrame) or the list of traces (EventLog))

  • max_repetitions – Maximum number of consecutive repetitions for an activity

Returns:

Dictionary of variants aggregated based on the limit of consecutive repetitions for the same activity

Return type:

aggregated_variants