Package for Multi-Perspective Process Visualization
Project description
mpvis
A Python package for Multi-Perspective Process Visualization of event logs
Index
Installation
This package runs under Python 3.9+, use pip to install.
pip install mpvis
IMPORTANT To render and save generated diagrams, you will also need to install Graphviz
Documentation
This package has two main modules:
mpdfgto discover and visualize Multi-Perspective Directly-Follows Graphs (DFG)mddrtto discover and visualize Multi-Dimensional Directed-Rooted Trees (DRT)
Multi-Perspective Directly-Follows Graph (Discovery / Visualization)
Format event log
Using mpdfg.log_formatter you can format your own initial event log with the corresponding column names, based on pm4py standard way of naming logs columns.
The format dictionary to pass as argument to this function needs to have the following structure:
{
"case:concept:name": <Case Id>, # required
"concept:name": <Activity Id>, # required
"time:timestamp": <Timestamp>, # required
"start_timestamp": <Start Timestamp>, # optional
"org:resource": <Resource>, # optional
"cost:total": <Cost>, # optional
}
Each value of the dictionary needs to match the corresponding column name of the initial event log. If start_timestamp, org:resource and cost:total are not present in your event log, you can leave its values as blank strings.
from mpvis import mpdfg
import pandas as pd
raw_event_log = pd.read_csv("raw_event_log.csv")
format_dictionary = {
"case:concept:name": "Case ID",
"concept:name": "Activity",
"time:timestamp": "Complete",
"start_timestamp": "Start",
"org:resource": "Resource",
"cost:total": "Cost",
}
event_log = mpdfg.log_formatter(raw_event_log, format_dictionary)
Discover Multi Perspective DFG
(
multi_perspective_dfg,
start_activities,
end_activities,
) = mpdfg.discover_multi_perspective_dfg(
event_log,
calculate_cost=True,
calculate_frequency=True,
calculate_time=True,
frequency_statistic="absolute-activity", # or absolute-case, relative-activity, relative-case
time_statistic="mean", # or sum, max, min, stdev, median
cost_statistic="mean", # or sum, max, min, stdev, median
)
Get the DFG diagram string representation
mpdfg_string = mpdfg.get_multi_perspective_dfg_string(
multi_perspective_dfg,
start_activities,
end_activities,
visualize_frequency=True,
visualize_time=True,
visualize_cost=True,
rankdir="TB", # or BT, LR, RL, etc.
diagram_tool="graphviz", # or mermaid
)
View the generated DFG diagram
Allows the user to view the diagram in interactive Python environments like Jupyter and Google Colab.
mpdfg.view_multi_perspective_dfg(
multi_perspective_dfg,
start_activities,
end_activities,
visualize_frequency=True,
visualize_time=True,
visualize_cost=True,
rankdir="TB", # or BT, LR, RL, etc.
)
Save the generated DFG diagram
mpdfg.save_vis_multi_perspective_dfg(
multi_perspective_dfg,
start_activities,
end_activities,
file_name="diagram",
visualize_frequency=True,
visualize_time=True,
visualize_cost=True,
format="png", # or pdf, webp, svg, etc.
rankdir="TB", # or BT, LR, RL, etc.
diagram_tool="graphviz", # or mermaid
)
Multi-Dimensional Directed-Rooted Tree (Discovery / Visualization)
Format event log
Using mddrt.log_formatter you can format your own initial event log with the corresponding column names based on pm4py standard way of naming logs columns.
The format dictionary to pass as argument to this function needs to have the following structure:
{
"case:concept:name": <Case Id>, # required
"concept:name": <Activity Id>, # required
"time:timestamp": <Timestamp>, # required
"start_timestamp": <Start Timestamp>, # optional
"org:resource": <Resource>, # optional
"cost:total": <Cost>, # optional
}
Each value of the dictionary needs to match the corresponding column name of the initial event log. If start_timestamp, org:resource and cost:total are not present in your event log, you can leave its values as blank strings.
from mpvis import mddrt
import pandas as pd
raw_event_log = pd.read_csv("raw_event_log.csv")
format_dictionary = {
"case:concept:name": "Case ID",
"concept:name": "Activity",
"time:timestamp": "Complete",
"start_timestamp": "Start",
"org:resource": "Resource",
"cost:total": "Cost",
}
event_log = mddrt.log_formatter(raw_event_log, format_dictionary)
Manual log grouping of activities
Groups specified activities in a process log into a single activity group.
activities_to_group = ["A", "B", "C"]
manual_grouped_log = mddrt.manual_log_grouping(
event_log=event_log,
activities_to_group=activities_to_group,
group_name="Grouped Activities" # Optional
)
Log pruning by number of variants
This function filters the event log to keep only the top k variants based on their frequency.Variants are different sequences of activities in the event log.
#k is the number of variants to keep
pruned_log_by_variants = mddrt.prune_log_based_on_top_variants(event_log, k=3)
Discover Multi-Dimensional DRT
drt = mddrt.discover_multi_dimensional_drt(
event_log,
calculate_cost=True,
calculate_time=True,
calculate_flexibility=True,
calculate_quality=True,
group_activities=False,
)
Automatic group of activities
grouped_drt = mddrt.group_drt_activities(drt)
Tree pruning by depth
Prunes the tree to the specified maximum depth.
#k is the specified maximum depth
mddrt.prune_tree_to_depth(drt, k=3)
Get the DRT diagram string representation
mddrt_string = mpdfg.get_multi_dimension_drt_string(
multi_dimensional_drt,
visualize_time=True,
visualize_cost=True,
visualize_quality=True,
visualize_flexibility=True
)
View the generated DRT diagram
Allows the user to view the diagram in interactive Python environments like Jupyter and Google Colab.
mpdfg.view_multi_dimensional_drt(
multi_dimensional_drt
visualize_time=True,
visualize_cost=True,
visualize_quality=True,
visualize_flexibility=True,
node_measures=["total"], # accepts also "consumed" and "remaining"
arc_measures=[], # accepts "avg", "min" and "max", or you can keep this argument empty
format="svg" # Format value should be a valid image extension like 'jpg', 'png', 'jpeq' or 'webp
)
WARNING Not all output file formats of Graphviz are available to display in environments like Jupyter Notebook or Google Colab.
Save the generated DRT diagram
mpdfg.save_vis_multi_dimensional_drt(
multi_dimensional_drt
file_path="diagram",
visualize_time=True,
visualize_cost=True,
visualize_quality=True,
visualize_flexibility=True,
node_measures=["total"], # accepts also "consumed" and "remaining"
arc_measures=[], # accepts "avg", "min" and "max", or you can keep this argument empty
format="svg", # or pdf, webp, svg, etc.
)
Examples
Checkout Examples to see the package being used to visualize an event log of a mining process.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mpvis-0.0.1.tar.gz.
File metadata
- Download URL: mpvis-0.0.1.tar.gz
- Upload date:
- Size: 11.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab382dbe350595c8913f51a8c2f5bb1033f34ab30e41614de8cc714abfa350b7
|
|
| MD5 |
78d6d4fc1fcc63c864aaf2b4c8001354
|
|
| BLAKE2b-256 |
ec24becc122729cee7151d84a66ff385452f345ebf1cd32f0714507b851caa17
|
Provenance
The following attestation bundles were made for mpvis-0.0.1.tar.gz:
Publisher:
python-publish.yml on nicoabarca/mpvis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mpvis-0.0.1.tar.gz -
Subject digest:
ab382dbe350595c8913f51a8c2f5bb1033f34ab30e41614de8cc714abfa350b7 - Sigstore transparency entry: 161912604
- Sigstore integration time:
-
Permalink:
nicoabarca/mpvis@50af0a582630269e6e28ce97178d8c8fee3ceef6 -
Branch / Tag:
refs/tags/v0.0.2-alpha - Owner: https://github.com/nicoabarca
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@50af0a582630269e6e28ce97178d8c8fee3ceef6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mpvis-0.0.1-py3-none-any.whl.
File metadata
- Download URL: mpvis-0.0.1-py3-none-any.whl
- Upload date:
- Size: 66.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ad5ded16c9469364148325bc4c4f9e29dc12b870914a767d79305ee81abad4e
|
|
| MD5 |
35f33201458339ed7ab4418896079787
|
|
| BLAKE2b-256 |
c4e182fe75166b279771ea5aaa2e1a1b5d4f5ed2f2345eba0c37e31e2fa11078
|
Provenance
The following attestation bundles were made for mpvis-0.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on nicoabarca/mpvis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mpvis-0.0.1-py3-none-any.whl -
Subject digest:
8ad5ded16c9469364148325bc4c4f9e29dc12b870914a767d79305ee81abad4e - Sigstore transparency entry: 161912605
- Sigstore integration time:
-
Permalink:
nicoabarca/mpvis@50af0a582630269e6e28ce97178d8c8fee3ceef6 -
Branch / Tag:
refs/tags/v0.0.2-alpha - Owner: https://github.com/nicoabarca
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@50af0a582630269e6e28ce97178d8c8fee3ceef6 -
Trigger Event:
release
-
Statement type: