pm4py.algo.filtering.polars.attributes.attributes_filter 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.filtering.polars.attributes.attributes_filter.Parameters(*values)[source]#
Bases:
Enum- ATTRIBUTE_KEY = 'pm4py:param:attribute_key'#
- ACTIVITY_KEY = 'pm4py:param:activity_key'#
- CASE_ID_KEY = 'pm4py:param:case_id_key'#
- DECREASING_FACTOR = 'decreasingFactor'#
- POSITIVE = 'positive'#
- STREAM_FILTER_KEY1 = 'stream_filter_key1'#
- STREAM_FILTER_VALUE1 = 'stream_filter_value1'#
- STREAM_FILTER_KEY2 = 'stream_filter_key2'#
- STREAM_FILTER_VALUE2 = 'stream_filter_value2'#
- KEEP_ONCE_PER_CASE = 'keep_once_per_case'#
- pm4py.algo.filtering.polars.attributes.attributes_filter.get_attribute_values(df: polars.LazyFrame, attribute_key: str, parameters: Dict[str | Parameters, Any] | None = None) Dict[Any, int][source]#
Return list of attribute values contained in the specified column
- Parameters:
df – Polars LazyFrame
attribute_key – Attribute for which we want to known the values and the count
parameters – Possible parameters of the algorithm
- Returns:
Attributes in the specified column, along with their count
- Return type:
attributes_values_dict
- pm4py.algo.filtering.polars.attributes.attributes_filter.apply_numeric_events(df: polars.LazyFrame, int1: float, int2: float, parameters: Dict[str | Parameters, Any] | None = None) polars.LazyFrame[source]#
Apply a filter on events (numerical filter)
- Parameters:
df – LazyFrame
int1 – Lower bound of the interval
int2 – Upper bound of the interval
parameters –
- Possible parameters of the algorithm:
Parameters.ATTRIBUTE_KEY => indicates which attribute to filter positive => keep or remove events?
- Returns:
Filtered LazyFrame
- Return type:
filtered_df
- pm4py.algo.filtering.polars.attributes.attributes_filter.apply_numeric(df: polars.LazyFrame, int1: float, int2: float, parameters: Dict[str | Parameters, Any] | None = None) polars.LazyFrame[source]#
Filter LazyFrame on attribute values (filter cases)
- Parameters:
df – LazyFrame
int1 – Lower bound of the interval
int2 – Upper bound of the interval
parameters –
- Possible parameters of the algorithm:
Parameters.ATTRIBUTE_KEY => indicates which attribute to filter Parameters.POSITIVE => keep or remove traces with such events?
- Returns:
Filtered LazyFrame
- Return type:
filtered_df
- pm4py.algo.filtering.polars.attributes.attributes_filter.apply_events(df: polars.LazyFrame, values: List[str], parameters: Dict[str | Parameters, Any] | None = None) polars.LazyFrame[source]#
Filter LazyFrame on attribute values (filter events)
- Parameters:
df – LazyFrame
values – Values to filter on
parameters –
- Possible parameters of the algorithm, including:
Parameters.ATTRIBUTE_KEY -> Attribute we want to filter Parameters.POSITIVE -> Specifies if the filter should be applied including traces (positive=True) or excluding traces (positive=False)
- Returns:
Filtered LazyFrame
- Return type:
df
- pm4py.algo.filtering.polars.attributes.attributes_filter.apply(df: polars.LazyFrame, values: List[str], parameters: Dict[str | Parameters, Any] | None = None) polars.LazyFrame[source]#
Filter LazyFrame on attribute values (filter traces)
- Parameters:
df – LazyFrame
values – Values to filter on
parameters –
- Possible parameters of the algorithm, including:
Parameters.CASE_ID_KEY -> Case ID column in the LazyFrame Parameters.ATTRIBUTE_KEY -> Attribute we want to filter Parameters.POSITIVE -> Specifies if the filter should be applied including traces (positive=True) or excluding traces (positive=False)
- Returns:
Filtered LazyFrame
- Return type:
df
- pm4py.algo.filtering.polars.attributes.attributes_filter.filter_df_on_attribute_values(df: polars.LazyFrame, values: List[str], case_id_glue: str = 'case:concept:name', attribute_key: str = 'concept:name', positive: bool = True) polars.LazyFrame[source]#
Filter LazyFrame on attribute values
- Parameters:
df – LazyFrame
values – Values to filter on
case_id_glue – Case ID column in the LazyFrame
attribute_key – Attribute we want to filter
positive – Specifies if the filtered should be applied including traces (positive=True) or excluding traces (positive=False)
- Returns:
Filtered LazyFrame
- Return type:
df
- pm4py.algo.filtering.polars.attributes.attributes_filter.filter_df_keeping_activ_exc_thresh(df: polars.LazyFrame, thresh: int, act_count0: Dict[str, int] | None = None, activity_key: str = 'concept:name', most_common_variant: List[str] | None = None) polars.LazyFrame[source]#
Filter a LazyFrame keeping activities exceeding the threshold
- Parameters:
df – Polars LazyFrame
thresh – Threshold to use to cut activities
act_count0 – (If provided) Dictionary that associates each activity with its count
activity_key – Column in which the activity is present
most_common_variant – (If provided) List of activities in most common variant
- Returns:
Filtered LazyFrame
- Return type:
df
- pm4py.algo.filtering.polars.attributes.attributes_filter.filter_df_keeping_spno_activities(df: polars.LazyFrame, activity_key: str = 'concept:name', max_no_activities: int = 25) polars.LazyFrame[source]#
Filter a LazyFrame on the specified number of attributes
- Parameters:
df – LazyFrame
activity_key – Activity key in LazyFrame (must be specified if different from concept:name)
max_no_activities – Maximum allowed number of attributes
- Returns:
Filtered LazyFrame
- Return type:
df
- pm4py.algo.filtering.polars.attributes.attributes_filter.filter_df_relative_occurrence_event_attribute(df: polars.LazyFrame, min_relative_stake: float, parameters: Dict[Any, Any] | None = None) polars.LazyFrame[source]#
Filters the event log keeping only the events having an attribute value which occurs: - in at least the specified (min_relative_stake) percentage of events, when Parameters.KEEP_ONCE_PER_CASE = False - in at least the specified (min_relative_stake) percentage of cases, when Parameters.KEEP_ONCE_PER_CASE = True
- Parameters:
df – Polars LazyFrame
min_relative_stake – Minimum percentage of cases (expressed as a number between 0 and 1) in which the attribute should occur.
parameters – Parameters of the algorithm, including: - Parameters.ATTRIBUTE_KEY => the attribute to use (default: concept:name) - Parameters.KEEP_ONCE_PER_CASE => decides the level of the filter to apply (if the filter should be applied on the cases, set it to True).
- Returns:
Filtered Polars LazyFrame
- Return type:
filtered_df