Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The module explainer #60

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
6d01336
reformatted for linting bot
MarcusRost Oct 8, 2023
2c92387
Revert "reformatted for linting bot"
MarcusRost Oct 8, 2023
34fc182
Merge branch 'main' of https://github.com/signavio/bpmn2constraints
MarcusRost Oct 12, 2023
c2a4013
Added xml counterparts for all examples (#5)
MarcusRostSAP Nov 1, 2023
e61a158
Initial commit explainer module
MarcusRostSAP Feb 21, 2024
3ace9db
Some experimentation
MarcusRostSAP Feb 27, 2024
7ae2895
Tried a new heurstic
MarcusRostSAP Feb 28, 2024
c0b4ccf
Some code clean up
MarcusRostSAP Mar 1, 2024
956fdc1
Slight change in logic
MarcusRostSAP Mar 1, 2024
31fab70
added activation feature
MarcusRostSAP Mar 7, 2024
5b1b525
Made some changes to the activation and logic
MarcusRostSAP Mar 14, 2024
d174146
Updated notebook
MarcusRostSAP Mar 14, 2024
17889ce
some small logic changes
MarcusRostSAP Mar 14, 2024
bf00dc2
Notebook compile
MarcusRostSAP Mar 14, 2024
a2b3016
added shapley_values
MarcusRostSAP Mar 18, 2024
bd61c2f
Progress on shapely for traces
MarcusRostSAP Mar 21, 2024
78ac617
Added comments
MarcusRostSAP Mar 22, 2024
55ac8e7
Linting issues
MarcusRostSAP Mar 22, 2024
05b67ce
Linting
MarcusRostSAP Mar 22, 2024
7818b3a
Linting
MarcusRostSAP Mar 22, 2024
384e06d
more linting
MarcusRostSAP Mar 22, 2024
baf65df
More linting
MarcusRostSAP Mar 22, 2024
0397671
Linting
MarcusRostSAP Mar 22, 2024
813097d
Linting
MarcusRostSAP Mar 25, 2024
f5ef8b7
linter
MarcusRostSAP Mar 25, 2024
e760cde
Linter
MarcusRostSAP Mar 25, 2024
3f11afd
Linting
MarcusRostSAP Mar 25, 2024
2f059a9
Explainability (#7)
MarcusRostSAP Mar 25, 2024
7e2c836
Added minimal solution feature
MarcusRostSAP Apr 3, 2024
acda6a4
Linting
MarcusRostSAP Apr 3, 2024
f3bd947
Linter
MarcusRostSAP Apr 3, 2024
6288107
Linter
MarcusRostSAP Apr 3, 2024
11df388
Updated explainer
MarcusRostSAP Apr 23, 2024
c1a8211
trail commit
MarcusRostSAP Apr 23, 2024
9b04b6a
Optimized the algorithm for counterfactual
MarcusRostSAP Apr 23, 2024
dfce47a
Updated tutorial
MarcusRostSAP Apr 23, 2024
84a832e
Fixed weird bug
MarcusRostSAP Apr 24, 2024
3b17ada
Ran notebook again
MarcusRostSAP Apr 24, 2024
25bad93
Some progress
MarcusRostSAP Apr 29, 2024
de9ff73
Added cache to API calls
MarcusRostSAP Apr 30, 2024
f67caf3
Changed location of tests
MarcusRostSAP Apr 30, 2024
edfc5d7
Linting
MarcusRostSAP Apr 30, 2024
18c9294
Lint
MarcusRostSAP Apr 30, 2024
13b1d17
Lint
MarcusRostSAP Apr 30, 2024
a7831c9
Lint
MarcusRostSAP Apr 30, 2024
f804d5b
Lint
MarcusRostSAP Apr 30, 2024
dd045d2
Lint
MarcusRostSAP Apr 30, 2024
79faa02
Linter
MarcusRostSAP Apr 30, 2024
aaf815e
Linteer
MarcusRostSAP Apr 30, 2024
4a3d97f
added init_.py file
MarcusRostSAP May 2, 2024
b17cdec
Updated tutorial
MarcusRostSAP May 2, 2024
00bc962
asd
MarcusRostSAP May 2, 2024
1b60d24
Updated readme
MarcusRostSAP May 2, 2024
97ee880
Lint
MarcusRostSAP May 2, 2024
129bd46
Reformat code
MarcusRostSAP May 6, 2024
564bbcb
Reformat
MarcusRostSAP May 6, 2024
7dede08
Linter
MarcusRostSAP May 6, 2024
3cd3e09
Changed test wording
MarcusRostSAP May 6, 2024
a3c07ee
Changed file locations
MarcusRostSAP May 6, 2024
d5dfc94
Merge branch 'main' of github.com:MarcusRostSAP/bpmn2constraints
MarcusRostSAP May 6, 2024
29c9e0f
Added comments and changed logic
MarcusRostSAP May 24, 2024
f836c62
Linting
MarcusRostSAP May 24, 2024
9d22b45
Lint
MarcusRostSAP May 24, 2024
109f81e
Clean up
MarcusRostSAP Jun 5, 2024
1efe7db
Clean code
MarcusRostSAP Jun 5, 2024
aa6b2dd
Linter
MarcusRostSAP Jun 5, 2024
c7e5551
Linter
MarcusRostSAP Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,8 @@ dmypy.json
.idea/

.vscode/

# explainer Stuff
explainer/test.py
explainer/old_code.py
tutorial/conf.py
2 changes: 1 addition & 1 deletion bpmnconstraints/compiler/bpmn_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __compile(self):
self.__create_response_constraint()

def _create_gateway_constraints(self):
if self.__get_cfo_type() == XOR_GATEWAY:
if self.__get_cfo_type() in XOR_GATEWAY:
self.__create_exclusive_choice_constraint()

if self.__get_cfo_type() == AND_GATEWAY:
Expand Down
6 changes: 4 additions & 2 deletions bpmnconstraints/parser/bpmn_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ def validate_splitting_and_joining_gateway_cases(self):

item_indices = {item["name"]: index for index, item in enumerate(self.sequence)}
for cfo in self.sequence:
if cfo["is start"] and cfo["name"] == "XOR":
if cfo["is start"] and (cfo["type"] in DISCARDED_START_GATEWAYS):
cfo["is start"] = False
for successor in cfo["successor"]:
self.sequence[item_indices[successor["name"]]]["is start"] = True
if cfo["is end"] and cfo["name"] in GATEWAY_NAMES:
if cfo["is end"] and (
cfo["name"] in GATEWAY_NAMES or cfo["type"] == "exclusivegateway"
):
cfo["is end"] = False
for predecessor in cfo["predecessor"]:
self.sequence[item_indices[predecessor["name"]]]["is end"] = True
Expand Down
5 changes: 4 additions & 1 deletion bpmnconstraints/parser/xml_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ def __xml_to_dict(self, input_dict):
if key.startswith("@"):
new_dict[key[1:]] = value
elif key.endswith(":outgoing"):
new_dict["outgoing"].append(value)
if isinstance(value, list):
new_dict["outgoing"].extend(value)
else:
new_dict["outgoing"].append(value)
else:
new_dict[key] = value
return new_dict
Expand Down
1 change: 1 addition & 0 deletions bpmnconstraints/script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Entry point for bpmnsignal command. Verifies argument and runs parser."""

# pylint: disable=import-error
import argparse
import logging
Expand Down
4 changes: 3 additions & 1 deletion bpmnconstraints/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"exclusivegateway",
]

DISCARDED_START_GATEWAYS = ["exclusive_databased_gateway", "exclusivegateway"]

ALLOWED_ACTIVITIES = [
"task",
"event",
Expand Down Expand Up @@ -148,7 +150,7 @@
"OR",
]

XOR_GATEWAY = "exclusive_databased_gateway"
XOR_GATEWAY = ["exclusive_databased_gateway", "exclusivegateway"]
AND_GATEWAY = "parallelgateway"
OR_GATEWAY = "inclusivegateway"

Expand Down
1 change: 1 addition & 0 deletions bpmnconstraints/utils/plot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module for plotting functions.
"""

# pylint: disable=import-error

import matplotlib.pyplot as plt
Expand Down
844 changes: 844 additions & 0 deletions examples/advanced/student_project.xml

Large diffs are not rendered by default.

508 changes: 508 additions & 0 deletions examples/advanced/underwriter.xml

Large diffs are not rendered by default.

1,172 changes: 1,172 additions & 0 deletions examples/and_gates/longer_and.xml

Large diffs are not rendered by default.

514 changes: 514 additions & 0 deletions examples/and_gates/single_and.xml

Large diffs are not rendered by default.

688 changes: 688 additions & 0 deletions examples/combinations/nested_and_or.xml

Large diffs are not rendered by default.

868 changes: 868 additions & 0 deletions examples/combinations/nested_and_or_xor.xml

Large diffs are not rendered by default.

1,173 changes: 1,173 additions & 0 deletions examples/combinations/nested_and_xor.xml

Large diffs are not rendered by default.

694 changes: 694 additions & 0 deletions examples/combinations/nested_xor_or.xml

Large diffs are not rendered by default.

565 changes: 565 additions & 0 deletions examples/linear/linear_sequence.xml

Large diffs are not rendered by default.

738 changes: 738 additions & 0 deletions examples/loops/activity_in_loop.xml

Large diffs are not rendered by default.

918 changes: 918 additions & 0 deletions examples/loops/gateway_in_loop_back.xml

Large diffs are not rendered by default.

1,028 changes: 1,028 additions & 0 deletions examples/loops/gateway_in_loop_back_2.xml

Large diffs are not rendered by default.

921 changes: 921 additions & 0 deletions examples/loops/inner_xor_loop.xml

Large diffs are not rendered by default.

1,106 changes: 1,106 additions & 0 deletions examples/loops/loop_with_multiple_xor.xml

Large diffs are not rendered by default.

810 changes: 810 additions & 0 deletions examples/loops/nested_loop.xml

Large diffs are not rendered by default.

637 changes: 637 additions & 0 deletions examples/loops/simple_loop.xml

Large diffs are not rendered by default.

848 changes: 848 additions & 0 deletions examples/loops/two_activities_in_loop.xml

Large diffs are not rendered by default.

752 changes: 752 additions & 0 deletions examples/loops/two_outgoing_loops.xml

Large diffs are not rendered by default.

1,064 changes: 1,064 additions & 0 deletions examples/main_example/Credit_quote_creation_simplified_SAP Signavio.xml

Large diffs are not rendered by default.

677 changes: 677 additions & 0 deletions examples/misc/multiple_endings.xml

Large diffs are not rendered by default.

512 changes: 512 additions & 0 deletions examples/misc/multiple_starts.xml

Large diffs are not rendered by default.

781 changes: 781 additions & 0 deletions examples/misc/nested_lanes.xml

Large diffs are not rendered by default.

394 changes: 394 additions & 0 deletions examples/misc/no_start_no_end.xml

Large diffs are not rendered by default.

852 changes: 852 additions & 0 deletions examples/or_gates/single_or_gateway.xml

Large diffs are not rendered by default.

1,264 changes: 1,264 additions & 0 deletions examples/xor_gates/3_way_split_xor.xml

Large diffs are not rendered by default.

1,546 changes: 1,546 additions & 0 deletions examples/xor_gates/double_nested_trailing_values.xml

Large diffs are not rendered by default.

1,178 changes: 1,178 additions & 0 deletions examples/xor_gates/longer_xor.xml

Large diffs are not rendered by default.

924 changes: 924 additions & 0 deletions examples/xor_gates/multiple_xor.xml

Large diffs are not rendered by default.

1,109 changes: 1,109 additions & 0 deletions examples/xor_gates/nested_xor.xml

Large diffs are not rendered by default.

1,360 changes: 1,360 additions & 0 deletions examples/xor_gates/nested_xor_with_before_and_after_activities.xml

Large diffs are not rendered by default.

1,234 changes: 1,234 additions & 0 deletions examples/xor_gates/nested_xor_with_double_ending.xml

Large diffs are not rendered by default.

740 changes: 740 additions & 0 deletions examples/xor_gates/single_xor.xml

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions explainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Symbolic Explanations of Process Conformance Violations
This module is made by Marcus Rost, for his thesis subject, **Symbolic Explanations for Control-Flow Objects**.

The code should work properly, with some hard-coded parts that requires the data set for the signal code to function. This module is more seen as a proof of concept, where some core functions from explainability theory is utilized.

## Overview
The module mainly consists of 2 classes, ExplainerRegex and ExplainerSignal.

**ExplainerRegex** is meant to simulate a real event log and system, with traces and constraints, using regex patterns.

**ExplainerSignal** uses real event logs to calculate the explanations. This uses SAP Signavio's API to do so, but should in reality have it's own interpreter for the Signal queries, instead of having to make API calls.

Currently, the Signal code is sort of bad and specialized for the specific data set used. Hopefully, someone can see the value of what it done, and generalize it further.

There is also 2 Notebook's located in `explainer/tutorial`, but I recommend doing `bpmn2constraints/tutorial/tutorial.ipynb` first, to see how to do the configuration for the API works.
Empty file added explainer/__init__.py
Empty file.
Loading
Loading