pm4py.algo.decision_mining package#
PM4Py – A Process Mining Library for Python
Copyright (C) 2024 Process Intelligence Solutions UG (haftungsbeschränkt)
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
Submodules#
pm4py.algo.decision_mining.algorithm module#
PM4Py – A Process Mining Library for Python
Copyright (C) 2024 Process Intelligence Solutions UG (haftungsbeschränkt)
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.decision_mining.algorithm.Parameters(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
- ACTIVITY_KEY = 'pm4py:param:activity_key'#
- LABELS = 'labels'#
- pm4py.algo.decision_mining.algorithm.create_data_petri_nets_with_decisions(log: EventLog | DataFrame, net: PetriNet, initial_marking: Marking, final_marking: Marking) Tuple[PetriNet, Marking, Marking] [source]#
Given a Petri net, create a data Petri net with the decisions given for each place by the decision mining algorithm
Parameters#
- log
Event log
- net
Petri net
- initial_marking
Initial marking
- final_marking
Final marking
Returns#
- data_petri_net
Data petri net
- initial_marking
Initial marking (unchanged)
- final_marking
Final marking (unchanged)
- pm4py.algo.decision_mining.algorithm.get_decision_tree(log: EventLog | DataFrame, net: PetriNet, initial_marking: Marking, final_marking: Marking, decision_point=None, attributes=None, parameters: Dict[str | Parameters, Any] | None = None) Any [source]#
Gets a decision tree classifier on a specific point of the model
Parameters#
- log
Event log
- net
Petri net
- initial_marking
Initial marking
- final_marking
Final marking
- decision_point
Point of the process in which a decision happens: - if not specified, the method crashes, but provides a list of possible decision points - if specified, the method goes on and produce the decision tree
- attributes
Attributes of the log. If not specified, then an automatic attribute selection is performed.
- parameters
Parameters of the algorithm
Returns#
- clf
Decision tree
- feature_names
The names of the features
- classes
The classes
- pm4py.algo.decision_mining.algorithm.apply(log: EventLog | DataFrame, net: PetriNet, initial_marking: Marking, final_marking: Marking, decision_point=None, attributes=None, parameters: Dict[str | Parameters, Any] | None = None) Any [source]#
Gets the essential information (features, target class and names of the target class) in order to learn a classifier
Parameters#
- log
Event log
- net
Petri net
- initial_marking
Initial marking
- final_marking
Final marking
- decision_point
Point of the process in which a decision happens: - if not specified, the method crashes, but provides a list of possible decision points - if specified, the method goes on and produce the decision tree
- attributes
Attributes of the log. If not specified, then an automatic attribute selection is performed.
- parameters
Parameters of the algorithm
Returns#
- X
features
- y
Target class
- class_name
Target class names
- pm4py.algo.decision_mining.algorithm.get_decisions_table(log0, net, initial_marking, final_marking, attributes=None, use_trace_attributes=False, k=1, pre_decision_points=None, trace_attributes=None, parameters=None)[source]#
Gets a decision table out of a log and an accepting Petri net
Parameters#
- log0
Event log
- net
Petri net
- initial_marking
Initial marking
- final_marking
Final marking
- attributes
List of attributes which are considered (if not provided, all the attributes are considered)
- use_trace_attributes
Include trace attributes in the decision table
- k
Number that determines the number of last activities to take into account
- pre_decision_points
List of Strings of place Names that have to be considered as decision points. If not provided, the decision points are inferred from the Petri net
- trace_attributes
List of trace attributes to consider
- parameters
Possible parameters of the algorithm
Returns#
- I
decision table
- decision_points
The decision points as places of the Petri net, which are the keys of a dictionary having as values the list of transitions that are target
- pm4py.algo.decision_mining.algorithm.prepare_event_log(log)[source]#
If trace attributes are considered, it is possible that trace attributes have the same name as event attributes. To tackle this issue, the attributes get renamed. For trace attributes, we add “t_” at the beginning of the dictionary keys. For event attributes, we add “e_” at the beginning of the dict keys. :param log: :return:
- pm4py.algo.decision_mining.algorithm.prepare_attributes(attributes)[source]#
Method that “e_” in front of every attribute if trace attributes are considered. :param attributes: List of event attributes that the user wants to consider. :return: list of edited attribute names
- pm4py.algo.decision_mining.algorithm.get_decision_points(net, labels=False, pre_decision_points=None, parameters=None)[source]#
The goal is to get all decision places. These are places where there are at least two outgoing arcs. :type labels:
bool
:param net: Petri Net where decision points are discovered (places with at least two outgoing arcs) :param labels: If someone wants to get the labels of the transitions after a decision point and not the “ID” :return:
- pm4py.algo.decision_mining.algorithm.get_attributes(log, decision_points, attributes, use_trace_attributes, trace_attributes, k, net, initial_marking, final_marking, decision_points_names, parameters=None)[source]#
- This method aims to construct for each decision place a table where for each decision place a list if given with the
label of the later decision and as value the given attributes
- Parameters:
log – Log on which the method is applied
alignments – Computed alignments for a log and a model
decision_points – Places that have multiple outgoing arcs
attributes – Attributes that are considered
use_trace_attributes – If trace attributes have to be considered or not
trace_attributes – List of trace attributes that are considered
k – Taking k last activities into account
- Returns:
Dictionary that has as keys the decision places. The value for this key is a list.
The content of these lists are tuples. The first element of these tuples is information regrading the attributes, the second element of these tuples is the transition which chosen in a decision.
- pm4py.algo.decision_mining.algorithm.encode_target(df, target_column)[source]#
Add column to df with integers for the target. Method taken from: http://chrisstrelioff.ws/sandbox/2015/06/08/decision_trees_in_python_with_scikit_learn_and_pandas.html Args —- df – pandas DataFrame. target_column – column to map to int, producing
new Target column.
Returns#
df_mod – modified DataFrame. targets – list of target names.