pm4py.algo.querying.llm.abstractions.log_to_variants_descr 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.querying.llm.abstractions.log_to_variants_descr.Parameters(*values)[source]#

Bases: Enum

INCLUDE_FREQUENCY = 'include_frequency'#
INCLUDE_PERFORMANCE = 'include_performance'#
MAX_LEN = 'max_len'#
RELATIVE_FREQUENCY = 'relative_frequency'#
RESPONSE_HEADER = 'response_header'#
PRIMARY_PERFORMANCE_AGGREGATION = 'primary_performance_aggregation'#
SECONDARY_PERFORMANCE_AGGREGATION = 'secondary_performance_aggregation'#
ACTIVITY_KEY = 'pm4py:param:activity_key'#
TIMESTAMP_KEY = 'pm4py:param:timestamp_key'#
CASE_ID_KEY = 'pm4py:param:case_id_key'#
pm4py.algo.querying.llm.abstractions.log_to_variants_descr.abstraction_from_variants_freq_perf_list(vars_list: List[Tuple[List[str], int, float, float]], parameters: Dict[Any, Any] | None = None) → str[source]#

Obtains a textual abstraction from a list of variants provided along their frequency and performance values. Each variant of the list is expressed in the form:

(('A', 'B', 'C'), 1000, 86400.0, 172800.0)

where (‘A’, ‘B’, ‘C’) is the tuple of activities executed in the variant, 1000 is the number of occurrences of this variant in the event log, 86400.0 is an aggregation (mean) of the throughput times of the cases belonging to this variant, 172800.0 is an aggregation (stdev, so standard deviation) of the throughput times of these cases.

Minimal viable example:

from pm4py.algo.querying.llm.abstractions import log_to_variants_descr

vars_list = [(('A', 'B', 'C'), 1000, 86400.0, 172800.0), (('A', 'B'), 500, 3600.0, 43200.0)]
print(log_to_variants_descr.abstraction_from_variants_freq_perf_list(vars_list))
Parameters:
  • vars_list – List of variants, expressed as explained above

  • parameters –

    Optional parameters of the algorithm, including:

    • Parameters.RELATIVE_FREQUENCY => decides if the the frequency of the variants should be normalized to a relative frequency

    • Parameters.PRIMARY_PERFORMANCE_AGGREGATION => primary performance metric to be used to express the performance of the arcs (e.g., mean). Available options: mean, median, stdev, min, max, sum

    • Parameters.SECONDARY_PERFORMANCE_AGGREGATION => secondary performance metric to be used to express the performance of the arcs (e.g., stdev). Available options: mean, median, stdev, min, max, sum

    • Parameters.MAX_LEN => desidered length of the textual abstraction

    • Parameters.RESPONSE_HEADER => includes an header in the textual abstraction, which explains the context

    • Parameters.INCLUDE_FREQUENCY => includes the frequency of the arcs in the textual abstraction

    • Parameters.INCLUDE_PERFORMANCE => includes the performance of the arcs in the textual abstraction

Returns:

Textual abstraction of the variants

Return type:

textual_abstraction

pm4py.algo.querying.llm.abstractions.log_to_variants_descr.compute_perf_aggregation(perf_values: List[float], perf_agg: str) → float[source]#

Computes an aggregation of a list of performance values

Minimal viable example:

compute_perf_aggregation([3600.0, 7200.0], ‘mean’)

Parameters:
  • perf_values – List of performance values

  • perf_agg – Desired aggregation (mean, median, stdev, sum, min, max)

Returns:

Aggregated value

Return type:

agg_value

pm4py.algo.querying.llm.abstractions.log_to_variants_descr.apply(log_obj: EventLog | EventStream | DataFrame, parameters: Dict[Any, Any] | None = None) → str[source]#

Gets the textual abstraction of the directly-follows graph computed on the provided log object.

Minimal viable example:

import pm4py
from pm4py.algo.querying.llm.abstractions import log_to_dfg_descr

log = pm4py.read_xes('tests/input_data/running-example.xes')
print(log_to_dfg_descr.apply(log))
Parameters:
  • log_obj – Log object (event log / Pandas dataframe)

  • parameters –

    Optional Parameters of the algorithm, including:

    • Parameters.ACTIVITY_KEY => the attribute to be used as activity

    • Parameters.TIMESTAMP_KEY => the attribute to be used as timestamp

    • Parameters.CASE_ID_KEY => the attribute to be used as case ID

    • Parameters.RELATIVE_FREQUENCY => (boolean) decides if the frequency DFG should be normalized to a relative frequency

    • Parameters.INCLUDE_FREQUENCY => includes the frequency of the arcs in the textual abstraction

    • Parameters.INCLUDE_PERFORMANCE => includes the performance of the arcs in the textual abstraction

    • Parameters.MAX_LEN => desidered length of the textual abstraction

    • Parameters.RESPONSE_HEADER => includes an header in the textual abstraction, which explains the context

    • Parameters.PRIMARY_PERFORMANCE_AGGREGATION => primary performance metric to be used to express the performance of the arcs (e.g., mean). Available options: mean, median, stdev, min, max, sum

    • Parameters.SECONDARY_PERFORMANCE_AGGREGATION => secondary performance metric to be used to express the performance of the arcs (e.g., stdev). Available options: mean, median, stdev, min, max, sum

Returns:

Textual abstraction

Return type:

textual_abstraction