Causal Process Discovery package
This package provides tools and algorithms for performing causal process discovery on raw process tabular data.The causal discovery is built on the
baseline of underlying process model and is driven by the process constraints, which can be captured in sax.causal_process_discovery.prior_knowledge.PriorKnowledge
and passed as input to causal execution discovery algorithms.
The outcome representation of the causal discovery algorithm is captured in the sax.process_data.discovery_result.ResultInfo
.
Subpackages
Submodules
sax.core.causal_process_discovery.causal_constants module
- class sax.core.causal_process_discovery.causal_constants.Algorithm(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
Enum representing causal discovery algorithms
LINGAM: DirectLINGAM algorithm
- LINGAM = 'Lingam'
- POSITIVE_LINGAM = 'positive_lingam'
- class sax.core.causal_process_discovery.causal_constants.Modality(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
Enum representing causal discovery modalities
PARENT: Parent anchor modality, where the examined time relationship between activities A->B->C is B-A and C-A (A is the parent activity and we examine the duration of B after A, and the duration of C which is combined durations of B after A and C after B)
CHAIN: Chain anchor modality, where the examined time relationships are between time intervals of each activity timestamp to the initial first activity timestamp
- CHAIN = 'Chain'
- PARENT = 'Parent'
- classmethod from_string(value)
sax.core.causal_process_discovery.causal_discovery module
- sax.core.causal_process_discovery.causal_discovery.discover_causal_dependencies(dataObject: RawEventData, variants: List[str] | None = None, algorithm: Algorithm | None = Algorithm.POSITIVE_LINGAM, modality: Modality | None = Modality.CHAIN, prior_knowledge: bool | None = True, depth: int = 1) CausalResultInfo
Create causal execution dependency model for the given event log represented by the dataobject
- Parameters:
dataObject (RawEventData) -- event log
variants (Optional[List[str]], optional) -- a List of one or more variant specifications to perform causal discovery on , optional (if not specified will perform causal discovery on the whole event log)
variant (Optional[Algorithm], optional) -- Algorithm to use for causal discovery, defaults to Lingam
modality (Optional[Modality], optional) -- Anchor modality to use for discovery, defaults to CHAIN modality
prior_knowledge (Optional[bool], optional) -- whether to use prior knowledge, defaults to False
- Raises:
TypeError -- in case the event log is not of appropriate format
- Returns:
causal dependency model representation
- Return type:
- sax.core.causal_process_discovery.causal_discovery.get_data_causal_representation(dataframe: RawEventData, modality, prior_knowledge, p_value_threshold, variants: List[str] | None = None)
The purpose of this function is to take a raw event log as input and output a dictionary representation of the causal model discovered from this event log. :param dataframe: A pandas dataframe containing the raw event log data. :type dataframe: RawEventData :param modality: Anchor modality to use for discovery, defaults to CHAIN modality :type modality: Optional[Modality], optional :param prior_knowledge: whether to use prior knowledge, defaults to False :type prior_knowledge: Optional[bool], optional :param p_value_threshold: a threshold for casual strength coefficient, edges with weights bellow this coefficient will not be presented :type p_value_threshold: float :param variants: a List of one or more variant specifications to perform causal discovery on , optional (if not specified will perform causal discovery on the whole event log) :type variants: Optional[List[str]], optional :return: A dictionary representing the causal model, where each key is a tuple representing a transition between two activities, and the value is the strength of that transition as determined causal discovery. :rtype: dict
- sax.core.causal_process_discovery.causal_discovery.get_model_causal_representation(model, p_value_threshold)
The purpose of this function is to take a causal model which is an adjacency matrix and create a dictionary representing this model, optionally filtering out edges with coefficient weights below specified threshold. :param model The causal model represented by CausalResultInfo object :type model CausalResultInfo :param p_value_threshold: a threshold for casual strength coefficient, edges with weights bellow this coefficient will not be presented :type p_value_threshold: float
- Returns:
A dictionary representing the causal model, where each key is a tuple representing a transition between two activities, and the value is the strength of that transition as determined causal discovery.
- Return type:
dict
- sax.core.causal_process_discovery.causal_discovery.view_causal_dependencies(dependencies: CausalResultInfo, p_value_threshold: float = None) Digraph
View the causal dependency model graph
- Parameters:
dependencies (CausalResultInfo) -- causal dependency model representation
p_value_threshold (float, optional) -- threshold for displaying causal relationships, no edges with coefficients less than specified will be displayed, defaults to None
- Returns:
graph
- Return type:
graphviz.Digraph
sax.core.causal_process_discovery.prior_knowledge module
- class sax.core.causal_process_discovery.prior_knowledge.PriorKnowledge(data: DataFrame, threshold=0.5)
Bases:
object
Prior knowledge representation for a particular event log. This object should be created and passed to the causal dependency discovery algorithm in case the user intends to run the algorithm with prior knowledge. The rules for creation of prior knowledge matrix are described here https://lingam.readthedocs.io/en/stable/tutorial/pk_direct.html
- getPriorKnowledge()
Get the prior knowledge matrix embedded in this object
Returns
- np.ndarray
Prior knowledge matrix
- make_prior_knowledge_graph()
# Assisted by WCA for GP # Latest GenAI contribution: granite-20B-code-instruct-v2 model Creates a graphviz.Digraph object representing the prior knowledge embedded in this object.
Parameters
None
Returns
- graphviz.Digraph
Graphviz Digraph object representing the prior knowledge